switch the default database on the fly - 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: switch the default database on the fly (/showthread.php?tid=11662) |
switch the default database on the fly - El Forum - 09-18-2008 [eluser]Dave Rau[/eluser] Often I have the need to change databases but from within the same CI app; what methods do you folks use to swap databases (and/or tables) on the fly? Is there a shortcut I can use to specify multiple database names, but keeping the same connection settings like server name, user/pass, etc.? switch the default database on the fly - El Forum - 09-18-2008 [eluser]GSV Sleeper Service[/eluser] you'll have to set up each db in the database config using 'groups' - http://ellislab.com/codeigniter/user-guide/database/configuration.html switch the default database on the fly - El Forum - 09-18-2008 [eluser]Dave Rau[/eluser] What if all of the config settings are the same except the database name? Is there some shorthand I can use for that? Code: $db['default']['hostname'] = "localhost"; I want the other_db group to inherit all of the properties of the default group except database name; any suggestions on how to do that? switch the default database on the fly - El Forum - 09-18-2008 [eluser]johnwbaxter[/eluser] ctrl C, ctrl V |