CodeIgniter Forums
How can I use mutil-databases group?? - 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: How can I use mutil-databases group?? (/showthread.php?tid=45834)



How can I use mutil-databases group?? - El Forum - 10-07-2011

[eluser]Unknown[/eluser]
Hi there.
I want to use several databases group in a server.
I have been searching for this but some of them are not for the latest version of CI.
Anyways I figured it out that I can access other DB group with following code:
Code:
$this->db_name = $this->load->database('db_name',TRUE);
and I can use it like this:
Code:
$this->db_name->get('table_name');

But I don't want to type every time when I tried to access other DB group.
How can I load the first line of code automatically in the Controller or Model so I can just use the second line of the code above.

I think there are some way like modifying session.php or make my own library etc.
But I don't get it yet.
Would somebody help me, please?
Thank you!

P.s sorry for my bad English, it's my second language.