I am not having much luck detecting when a database query in Codeigniter returns zero results. I have had a good read of the notes on the PHP count function but am none the
i'm dowing this and it workd for me
Controller
$id = $this->session->userdata('id');
if($this->model_users->if_user_dont_have_email($id)){
....
}
Model Users
public function if_user_dont_have_email($id){
$query = $this->db->query("SELECT email FROM users WHERE id='$id'");
if ($query->num_rows() > 0) {
$row = $query->row_array();
if(empty($row['email'])){
return true;
}else{
return false;
}
}
}