0

我一直在使用这些代码行在 codeigniter 中连接多个数据库,但出现错误。我的新数据库连接用于 new_group。

$this->new_group = $this->CI->load->database('new_group', TRUE); 
$q = $this->new_group->query("SELECT* FROM mytable ORDER BY id DESC");

在非对象上调用成员函数 database()。

等待答复。谢谢

4

2 回答 2

2

试试这个http://codeigniter.com/forums/viewthread/145901/

$db['new_group']['pconnect'] = FALSE;

我没试过...

于 2012-10-01T11:21:28.323 回答
2

从加载命令中删除 ->CI

$this->new_group = $this->load->database('new_group', TRUE); 
$q = $this->new_group->query("SELECT* FROM mytable ORDER BY id DESC");

或者您必须先加载 CI 对象:

$this->CI =& get_instance();
$this->new_group = $this->CI->load->database('new_group', TRUE); 
$q = $this->new_group->query("SELECT* FROM mytable ORDER BY id DESC");
于 2012-10-01T12:02:06.570 回答