Welcome Guest, Not a member yet? Register   Sign In
PDO sqlsrv for MSSQL on CodeIgniter 2.1.1
#1

[eluser]mraliks[/eluser]
I'm attempting to use the pdo driver to connect to the Microsoft sql 2008 server using CI's default load->database() class but receive an Internal Server Error. I have all PDO drivers and SQLSRV drivers installed, but still get a 500 response.

However, when I use PDO to connect to the DB without CI's load->database() class, it works fine.

Help?! I've tried countless # of things including checking drivers, running through the pdo_driver.php script, changing db config settings, but no luck.

Below is my configuration code (database.php):

Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'sqlsrv:server=TESTBOX';
$db['default']['username'] = 'user';
$db['default']['password'] = 'Pass#1';
$db['default']['database'] = 'DB_Test';
$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

Thanks in advance!!

Update:
1. Connecting to a mysql database works fine, but in my company's environment we must be using MSSQL 2008.
2. I updated my pdo driver files from github and the error still persists.
#2

[eluser]mraliks[/eluser]
Issue fixed (so far) by downloading the most recent GitHub code rather than CI v. 2.1.1

In the GitHub source code, the PDO drivers are significantly updated and work well with PDO SQLSRV.

#3

[eluser]ngatcharius[/eluser]
There is an error using
Code:
$db['default']['hostname'] = 'sqlsrv:Server=(local)';
change dbname to Database

Code:
empty($this->database) OR $this->hostname .= ';dbname='.$this->database;
to
Code:
empty($this->database) OR $this->hostname .= ';Database='.$this->database;
In pdo_drivers on line 81
#4

[eluser]jonldavis[/eluser]
I've been using the sqlsrv driver for a month or so with CI v2.1.0 successfully, but I've been wanting to take advantage of some of the PDO features you can't get with the plain driver (my DBA wants to use output parameters from stored procedures, and it seems that isn't supported by the MS driver directly).

However, when I pulled the v2.1.2 code and copied it to my server, my database connection was totally hosed, wouldn't even connect with sqlsrv or PDO.

Checking in database/drivers/sqlsrv, it seems to have reverted back to the previous connection problem (http://ellislab.com/forums/viewthread/197527/).

Don't know enough about PDO to look into it, though I tried ngatcharius's fix without success.

For now, stepping back to CI v2.1.0 until I have time to figure out what's wrong.




Theme © iAndrew 2016 - Forum software by © MyBB