Welcome Guest, Not a member yet? Register   Sign In
Call to a member function real_escape_string() on boolean
#1

Hello

I recently started using codeigniter 3.1.6 and I am facing a strange error whenever I use where function of query builder.

Details :

When I hit the query string like below 
select * from user where user_name = "abc@xyz.com" and user_id = 1;
I get the desired result.

When I try to use query builder like below
Code:
   public function get($where = array(), $fields = array(), $groupBy = array(), $offset = 0, $limit = 0)
   {  
       foreach ($where as $key => $value) {
           $this->db_slave->where($key, $value);
       }

       $this->db_slave->select(implode(',', $fields));
       if (isset($offset) && $offset !== 0) {
           $this->db_slave->offset($offset);
       }
       
       if (isset($limit) && $limit !== 0) {
           $this->db_slave->limit($limit);
       }
       
       if (is_array($groupBy)) {
           $this->db_slave->group_by($groupBy);
       }
       
       $query = $this->db_slave->get(self::TABLE_NAME);
       return $query->result_array();
   }
I get an error as

Call to a member function real_escape_string() on boolean in mysqli_driver.php line 391
which has the function as


protected function _escape_str($str)

{

        return $this->conn_id->real_escape_string($str);
}


I am not sure what is causing this problem ... I would really appriciate any help on this.

BTW, When I use query builder to have only primary id on where clause it works without any problem..
The problem is only when there are some strings involved....

The above function is called like 

Code:
    public function check_valid_current_password($current_password)
    {
        $this->CI->load->model('user_model');
        $where['user_email'] = $this->CI->current_user['user_email'];
        //$where['user_password'] = md5($current_password);
        
        $check = $this->CI->user_model->get($where, array('user_id'));

        if (!isset($check[0]['user_id']) || $check[0]['user_id'] == 0) {
            $this->CI->form_validation->set_message(__FUNCTION__, 'Wrong password specified for this user.');
            
            return FALSE;
        }
        
        return TRUE;
    }
From a library I created to extend form validation class.
Reply


Messages In This Thread
Call to a member function real_escape_string() on boolean - by kaustubh.agrawal2000 - 11-08-2017, 04:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB