简体   繁体   中英

Codeigniter Database Forge with multiple DB connections

I use multiple DB connections in my Codeigniter application. When I load dbforge it loads it for the current db connection. How can I set dbforge so it work with the second DB connection?

In EE1 it used to be:

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:

$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

Examples of the old EE1 approach still working in EE2 here: http://expressionengine.com/forums/viewthread/213519/#992669

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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