致命错误:在非对象(Codignighter)上调用成员函数result()


Fatal error:Call to a member function result() on a non-object.(Codignighter)

代码如下:

public function get_id_model($email){
    $this->db->select('user_id');
    $this->db->where('email', $email);
    $query = $this->db->get('users');
    return $query->result();
}

此代码在本地运行良好。但是当我把项目推到000webhost时,它返回了空,尽管我的远程数据库包含数据。

Database.php

$db['remote']['hostname'] = 'xxx.000webhost.com';
$db['remote']['username'] = 'xxx';
$db['remote']['password'] = 'xxx';
$db['remote']['database'] = 'xxx';
$db['remote']['dbdriver'] = 'mysql';
$db['remote']['dbprefix'] = '';
$db['remote']['pconnect'] = TRUE;
$db['remote']['db_debug'] = TRUE;
$db['remote']['cache_on'] = FALSE;
$db['remote']['cachedir'] = '';
$db['remote']['char_set'] = 'utf8';
$db['remote']['dbcollat'] = 'utf8_general_ci';
$db['remote']['swap_pre'] = '';
$db['remote']['autoinit'] = TRUE;
$db['remote']['stricton'] = FALSE;
在Autoload.php

$autoload['libraries'] = array('database', 'session');

我错过什么了吗?

只需将数据库驱动程序从mysql更改为mysqli。您可以在config文件夹中的database.php文件中执行此操作。