multiple database connections - 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: multiple database connections (/showthread.php?tid=31066) |
multiple database connections - El Forum - 06-05-2010 [eluser]Unknown[/eluser] hello, trying to connect to a different database, one with a variable name. no matter what I do, ci keeps the old connection. following the userguide, in my model function I set up Code: $config['param'] = 'param'; in a method called later, Code: $config['newparam'] = 'param'; In desperation I have removed my database.php config to try all connections in this fashion, to no avail. pconnect is false for all, I have tried Code: $this->load->database($config,false); as well as Code: $this->different_db = $this->load->database($config); was wondering if anyone could lend a hand here, i'm nearly out of ideas. thanks, brandon multiple database connections - El Forum - 06-05-2010 [eluser]Unknown[/eluser] also tried closing the connection with Code: $this->database->close() and I would add it to the $db array but the database was just crated. a better code snippet: controller Code: makeuser($u,p$); Code: <?php brandon multiple database connections - El Forum - 06-06-2010 [eluser]pickupman[/eluser] Behold the great & mighty user guide. Your question is answered in the last section of the page. When you use multiple Db's you don't use $this->db but rather $DB1 and $DB2 (or whatever else you want). |