In a scenario I need to know the count of recordset a query will return, which in codeigniter can be done by $query->num_rows()
or $this->db->cou
$sql = "select count(*) as row from login WHERE firstname = '" . $username . "' AND password = '" . $password . "'";
$query = $this->db->query($sql);
print_r($query);exit;
if ($query->num_rows() == 1) {
return true;
} else {
return false;
}
We can also use
return $this->db->count_all('table_name');
or
$this->db->from('table_name');
return $this->db->count_all_result();
or
return $this->db->count_all_result('table_name');
or
$query = $this->db->query('select * from tab');
return $query->num_rows();