Function in model file:
function get_user_by_email($email)
{
//$this->consumer->where('email=', strtolower($email));
//$query = $this->consumer->get($this->table_name);
$query = $this->db->query('CALL get_user_by_email("'.strtolower($email).'")');
echo $query->num_rows();
}
This function returns error Call to a member function num_rows() on a non-object in
whereas the other functions in the same file returns the row count. Also tried the active record query. But the query also returns the same error.
I tried using result(), result_array()
also. But everything gives me error.
Thanks
Try
$email = strtolower($email);
$query = $this->db->query("CALL get_user_by_email('$email')");
if(is_object($query)){
echo $query->num_rows();
}else{
echo "Query Failed";
}
You might need to enclose $email
in braces to be certain it evaluates.
$query = $this->db->query("CALL get_user_by_email('{$email}')");
I used $this->db->reconnect();
to reconnect to the database before calling the store procedure. This resolved the issue
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.