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!
#2

[eluser]bapobap[/eluser]
My bad, pconnect to false fixes it. Not sure if I should keep pconnect to true but oh well!
#3

[eluser]Mirge[/eluser]
Saw this thread and was curious, thanks for posting back with your fix!




Theme © iAndrew 2016 - Forum software by © MyBB