1
I’m looking for the total number of lines of a query but keeps giving this error, I’ve tried to use the function Row(), rowCount() and even check if found any results to return and still not reached the solution
Fatal error: Call to a Member Function num_rows() on a non-object in C: wamp www topsamp-ci application models Servor_model.php on line 86
public function getVotosHoje($idServer){
$data = date('Y-m-d');
$select = array('id', 'data');
$where = "idServidor = '$idServer' AND data = '$data'";
$this->db->where($where);
$this->db->select($select);
$retorno = $this->db->get('votos')->result();
if($retorno->num_rows() > 0){
return $retorno->num_rows();
} else{
return false;
}
}
It worked, thank you!
– viniciussvl
@Viniciusaquino please mark the answer as accepted.
– Guilherme Nascimento
Puts dude, it worked but only returns me the last record of the table, to calling this method inside the foreach passing the id of each item: <?= $this->server->getVotosHoje($v->id); ?>
– viniciussvl
@Viniciusaquino I think I understood your need, I edited the answer, take a look again.
– Guilherme Nascimento
It didn’t work, it only returns me 2 records
– viniciussvl
@Viniciusaquino the problem is in your query probably because you limited by date
$data = date('Y-m-d');
, will only appear today’s records. Anything try like this$retorno = $this->db->get();

if($retorno->num_rows() > 0){
 return $retorno->result();
}
– Guilherme Nascimento
I’m sorry, I was looking at the data on the dashboard with the wrong account, it’s working normally, thanks for the help!
– viniciussvl