Codeigniter real_escape_string函数无法调用

时间:2017-06-14 10:35:36

标签: php codeigniter

我在模特中添加了以下一行

$this->db->close();

然后这段代码给了我一个错误

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

任何建议或建议都将不胜感激。

更新:这是我使用的配置。主数据库连接

$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 个答案:

答案 0 :(得分:1)

你的DBdriver是mysqli所以你必须使用real_escape_string(),因为它属于mysql dbdriver

您可以使用$ this-> db-> escape_str()或$ this-> db-> escapeign(codeigniter)函数