(solved) Database groups problems - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: (solved) Database groups problems (/showthread.php?tid=26761) |
(solved) Database groups problems - El Forum - 01-22-2010 [eluser]anthrt[/eluser] I have 2 database groups set in database.php, one is to power the website and the other is a phpBB3 forum in a seperate database. I have the two different configurations set in database.php. In one of the models where I need to retrieve stuff from the 2nd (non default) forum DB, I tried it with Code: $this->load->database('forum'); But it is trying to query the default database. I'm pretty sure it's because the database is being autoloaded. Obviously I don't want to have to manually load the database class in every controller and every method throughout the site. Am I wrong in this assumption? If not, is there any way to overcome this problem? Regards (solved) Database groups problems - El Forum - 01-22-2010 [eluser]rogierb[/eluser] Did you do Code: $forum_db = $this->load->database('forum'); Or did you use $this->db->query("select * from some_table")? (solved) Database groups problems - El Forum - 01-22-2010 [eluser]anthrt[/eluser] I originally had done it the latter way you had mentioned, however i've just changed the code to this: Code: $forum_db = $this->load->database('forum'); However.. Quote:Fatal error: Call to a member function query() on a non-object in /home/application/models/sitemodel.php on line 8 Regards (solved) Database groups problems - El Forum - 01-22-2010 [eluser]vitoco[/eluser] I think that you need the second parameter TRUE , to return the db object, like this Code: $forum_db = $this->load->database('forum' , true ); (solved) Database groups problems - El Forum - 01-23-2010 [eluser]anthrt[/eluser] Thanks vitoco, that's done it. |