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

时间:2016-10-01 15:05:15

标签: php database codeigniter

以下是代码:

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时,它返回了null,尽管我的远程数据库包含数据。

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

我错过了什么吗?

1 个答案:

答案 0 :(得分:-2)

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