Database.php settings for MSSQL database |
[eluser]cblosser[/eluser]
Hello, I'm a newbie to codeigniter and so far really love it. I used cakephp for a little while but was not thrilled with the documentation or lack of. I would like to use codeigniter for a project at work, but I would be required to use a MSSQL database. I searched through the forum and found lots about using ODBC, ADODB, ect, but nothing in detail as to how to format the database.php file. Here is what I have: A Microsoft SQL server running on Localhost username of "test" password of "password" database is "testdb" Below is one of the (unsuccessful) ways i've tried to configure this. $db['default']['hostname'] = "localhost:1433"; $db['default']['username'] = "test"; $db['default']['password'] = "password"; $db['default']['database'] = "testdb"; $db['default']['dbdriver'] = "mssql"; $db['default']['dbprefix'] = ""; $db['default']['active_r'] = TRUE; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; Can someone tell me what I'm doing wrong, or give me an example of a better way? Thanks so much, Chris
[eluser]JamesD[/eluser]
[quote author="cblosser" date="1197780969"]Hello, I'm a newbie to codeigniter and so far really love it. I used cakephp for a little while but was not thrilled with the documentation or lack of. I would like to use codeigniter for a project at work, but I would be required to use a MSSQL database. I searched through the forum and found lots about using ODBC, ADODB, ect, but nothing in detail as to how to format the database.php file. Here is what I have: A Microsoft SQL server running on Localhost username of "test" password of "password" database is "testdb" Below is one of the (unsuccessful) ways i've tried to configure this. $db['default']['hostname'] = "localhost:1433"; $db['default']['username'] = "test"; $db['default']['password'] = "password"; $db['default']['database'] = "testdb"; $db['default']['dbdriver'] = "mssql"; $db['default']['dbprefix'] = ""; $db['default']['active_r'] = TRUE; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; Can someone tell me what I'm doing wrong, or give me an example of a better way? Thanks so much, Chris[/quote] Have you checked the User Guide info on database configuration? http://ellislab.com/codeigniter/user-gui...ation.html
[eluser]cblosser[/eluser]
Yes, I've looked at all of that. It only gives an example of a mysql connection. I'm just not sure if i'm putting the right setting in the hostname for a mssql driver or odbc? Do I just put in local host, or do I need a full DSN there?
[eluser]JamesD[/eluser]
[quote author="cblosser" date="1197782028"]Yes, I've looked at all of that. It only gives an example of a mysql connection. I'm just not sure if i'm putting the right setting in the hostname for a mssql driver or odbc? Do I just put in local host, or do I need a full DSN there?[/quote] If CI is located on the same server as the MSSQL database is, then I would think localhost would be the correct hostname. Wouldn't the port number come into play if using DNS instead of localhost? Disclaimer Note: Personally, I haven't messed with MSSQL too much.... so, I'm not 100% :cheese: Here's another snippet from the guide (if it helps): [quote author="CodeIgniter User Guide"]For information on each of these values please see the configuration page. Or you can submit your database values as a Data Source Name. DSNs must have this prototype: $dsn = 'dbdriver://username:password@hostname/database'; $this->load->database('$dsn'); Note that if you use a DSN you will not be able to specify some of the default values like you can if you use a connection array.[/quote] Any avid MSSQL users out there that could shine some light?
[eluser]cblosser[/eluser]
Ok, I've figured it out. Apparently PHP has issues with the express version of sql server. I tried the normal settings on our production sql 2000 server and it worked like a charm. |
Welcome Guest, Not a member yet? Register Sign In |