Welcome Guest, Not a member yet? Register   Sign In
Changing db in the middle of a script

Hi guys Smile

I have CI autoloading the database library, so when the app starts it connects to database specified in my config/database.php

Now, in the middle of this app, I need to connect to a different database .. replacing the current connection.

How do I do this "the right way"? Smile

I tried doing
and supplying a new config, but that does absolutely nothing, as far as I can tell.


I got this to work:
Is that the proper way to do it?

And another question:
I use database based sessions (because of freak_auth), which means that when I connect to this new database, freak_auth no longer has access to the session it created in the beginning of the script. Any ideas how to fix that?

[eluser]Chris Newton[/eluser]
You can connect to multiple databases, without closing one out. See the documentation:


Bottom of the page.

Theme © iAndrew 2016 - Forum software by © MyBB