CodeIgniter Forums
SQL SERVER connection. - 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: SQL SERVER connection. (/showthread.php?tid=53438)



SQL SERVER connection. - El Forum - 07-24-2012

[eluser]josepichu[/eluser]
Hi !

In my project I work with a MySQL database, but I need in some cases connect to a mssql database to make some queries, and i don't know how can i do it.

I tried to define the mssql configuration in the database.php config file:

Code:
$active_group = 'mssql';

$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '*****';
$db['default']['dbdriver'] = 'mysql';

....


$db['mssql']['hostname'] = 'localhost';
$db['mssql']['username'] = 'root';
$db['mssql']['password'] = '******';
$db['default']['dbdriver'] = 'mssql';

...

But i can't to update the $active_group var to choose the mssql configuration in ejecution time.

¿How do you could do it?

Thanks!


SQL SERVER connection. - El Forum - 07-24-2012

[eluser]PhilTem[/eluser]
Please refer to the user's guide section Database - Connecting paragraph "Connecting to Multiple Databases" or here if you don't mind reading the nightly user's guide (and want to avoid scrolling Wink )