简体   繁体   English

具有多个数据库连接的Codeigniter Database Forge

[英]Codeigniter Database Forge with multiple DB connections

I use multiple DB connections in my Codeigniter application. 我在Codeigniter应用程序中使用了多个数据库连接。 When I load dbforge it loads it for the current db connection. 当我加载dbforge ,它将为当前数据库连接加载它。 How can I set dbforge so it work with the second DB connection? 如何设置dbforge,使其与第二个数据库连接一起工作?

In EE1 it used to be: 在EE1中,它曾经是:

mysql_select_db(<database name>);

or 要么

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
...
mysql_close($conn);

I believe looking at example code elsewhere you can still use this approach. 我相信,在其他地方查看示例代码,您仍然可以使用这种方法。

For EE2 try: 对于EE2,请尝试:

$this->EE->load->dbforge();
$db = $this->EE->load->database(‘default’, TRUE);

Where the first parameter is looking for the database config settings group. 第一个参数在哪里寻找数据库配置设置组。

More info here: http://ellislab.com/codeigniter/user-guide/database/connecting.html 此处提供更多信息: http : //ellislab.com/codeigniter/user-guide/database/connecting.html

Examples of the old EE1 approach still working in EE2 here: http://expressionengine.com/forums/viewthread/213519/#992669 此处仍然可以在EE2中使用旧EE1方法的示例: http : //expressionengine.com/forums/viewthread/213519/#992669

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM