Welcome Guest, Not a member yet? Register   Sign In
Accessing multiple databases
#1

[eluser]bapobap[/eluser]
Hello all,

I have a CI application, using Active Record, which works well.

I need to use another database for one single part of a model and I've tried using the code to connect to another database as defined in the docs:

Code:
$DB2 = $this->load->database('group_two', TRUE);

This works, however, even if I manually close the connection, the rest of my app from this point in the code forward, which would usually just use the autoloaded database, will try to use the group_two connection instead.

Is there any way to quickly connect to another database, then just revert back to the autoloaded database as normal? I guess I could use regular PHP to do this but I prefer to use AR if I can and I don't want to change my entire application to use $DB1 instead of $this->db just to allow 10 lines of code for $DB2 to work.

Any help would be appreciated!


Messages In This Thread
Accessing multiple databases - by El Forum - 07-09-2011, 10:09 AM
Accessing multiple databases - by El Forum - 07-09-2011, 10:38 AM
Accessing multiple databases - by El Forum - 07-09-2011, 10:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB