1

I have added the line below from my models

$this->db->close();

And then this code gives me an error

Severity: error --> Exception: Call to a member function real_escape_string() on boolean  

Any advice or suggestion would be appreciated.

UPDATE: Here are the configs I use. Main DB connection

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'is my host address',
    'username' => 'is my id',
    'password' => 'is my password',
    'database' => 'is my database name',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => APPPATH.'cache/db/',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);
5
  • 3
    if connection close is not necessary then don't close database connection. Commented Jun 14, 2017 at 10:40
  • Can you query anything against $this->db? Commented Jun 14, 2017 at 10:41
  • @Bhavin I have added $this->db->close() because there are too many sleep process which is caused by not disconnecting after desired job is done and I want to make sure all the connections are closed after they are done. Commented Jun 14, 2017 at 10:43
  • @Antony Yes. Of course. I only added the code where $this->db has some result to return Commented Jun 14, 2017 at 10:44
  • My guess is you are running a db operation after using db->close(). Commented Jun 14, 2017 at 11:26

1 Answer 1

2

Your DBdriver is mysqli so you have to use real_escape_string() because its belong from mysql dbdriver

You can use $this->db->escape_str() or $this->db->escape() function of codeigniter

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.