CodeIgniter Forums
cannot switch database groups - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: cannot switch database groups (/showthread.php?tid=37731)



cannot switch database groups - El Forum - 01-18-2011

[eluser]Neil_W[/eluser]
Hello,
I have multiple groups in my database.php file and I want to switch between them in code because I simply need to use different databases/tables at different times with different users.

In my controller constructor I have this:

function Admin()
{
parent::MY_Controller();
$this->load->library('session');
$this->load->database('l4session');
}

However, when I try and use the database it is still using 'default' rather than 'l4session', and I have not autoloaded database. If I modify $active_group to use 'l4session' it works fine. So it's as if passing in the parameter has no effect.

Am I doing something wrong?

Thanks for any help.


cannot switch database groups - El Forum - 01-18-2011

[eluser]Neil_W[/eluser]
Ah, I spotted my mistake Smile

Seem I have to load the database before I load the session library.