Oleksandr IY
Oleksandr IY

Reputation: 3116

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?

Upvotes: 0

Views: 1095

Answers (1)

Peter Lewis
Peter Lewis

Reputation: 1085

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

Upvotes: 0

Related Questions