Codeigniter real_escape_string function can't call

孤者浪人 提交于 2019-12-24 10:58:27

问题


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
);

回答1:


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



来源:https://stackoverflow.com/questions/44542320/codeigniter-real-escape-string-function-cant-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!