I am experiencing a rather intriguing problem, and I have no idea why.
Utilizing the code below, if a session id is set, the echo statement returns '1' - it finds the user with that session id in the database.. simple.
If however the user has logged out, and 'my_session_id' has been set to 0 such that no result is found in the database, the echo statement seems to be returning the number of rows in the table... I.E as though the only statement was $query=$this->db->get('users');
Any ideas as to why?
$session=$this->session->userdata('my_session_id');
$this->db->where('session',$session);
$query=$this->db->get('users');
$count=$query->num_rows();
//echo $session."<br>";
echo $count;
echo $this->db->last_query();. Can you check if appropriate query is formedWHERE `session` IS NULL? If you want to return the number of rows, then seecount_all_results().