![]() |
Change database in controller - 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: Change database in controller (/showthread.php?tid=22014) |
Change database in controller - El Forum - 08-27-2009 [eluser]huzzel[/eluser] Hi, i tried to add a dynamic database via dsn or $db but it wont connect :-( Code: function view($id){ Change database in controller - El Forum - 08-27-2009 [eluser]pistolPete[/eluser] Did you really just copy that line from the user guide and expected it to work? Code: $dsn = 'dbdriver://username:password@XXXX/database...'; You need to build the $dsn string using your config settings: Code: $dsn = 'mysql://'.$data['site']->mysql_user.':'.$data['site']->mysql_pw.'@'.$data['site']->mysql_ip.'/'.$data['site']->mysql_db.'; Change database in controller - El Forum - 08-27-2009 [eluser]huzzel[/eluser] yes and $db_current is still empty :-( Code: <?php Change database in controller - El Forum - 08-27-2009 [eluser]pistolPete[/eluser] Read the user guide: http://ellislab.com/codeigniter/user-guide/database/connecting.html Quote:Connecting to Multiple Databases Change database in controller - El Forum - 08-27-2009 [eluser]huzzel[/eluser] oh ^_^ thx for your help :-) i am really new to ci. I think it would be better if someone could create a new category here with "newbie questions" ^^ |