• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing multiple databases

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:

$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!

My bad, pconnect to false fixes it. Not sure if I should keep pconnect to true but oh well!

Saw this thread and was curious, thanks for posting back with your fix!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.