0
I wrote 2 possibilities to return the number of results using Codeigniter, follows:
public function get_num_indicados($id_usuario)
{
$query = $this->db->query("SELECT count(id_patrocinador) as num FROM usuarios WHERE id_patrocinador = ?", array($id_usuario));
$row = $query->row();
return $row->num;
}
public function get_num_indicados($id_usuario)
{
$query = $this->db->query("SELECT * FROM usuarios WHERE id_patrocinador = ?", array($id_usuario));
return $query->num_rows();
}
Doubt: Which is the right way and why? Indifferent? And how about performance for Mysql?
Buddy, I usually use either one, but I also use Count($this->model->Function()); which also solves...
– Sr. André Baill