Welcome Guest, Not a member yet? Register   Sign In
Can someone explain why the pdo for sqlsrv has such issues?
#1

[eluser]Unknown[/eluser]
I just installed codeigniter and got it to work with my pdo_sqlsrv but I had to manually edit the pdo_driver.php which I shouldn't have to do.

I had to edit like 98 and line 114 to be the following -

Code:
return new PDO('sqlsrv:Server=servername\instancename;Database=databasename', $this->username, $this->password, $this->options);

Because it wasn't parsing the information from my database.php file which is as follows -

Code:
$db['default']['hostname'] = 'sqlsrv:servername\instancename';
$db['default']['username'] = 'user';
$db['default']['password'] = 'pass';
$db['default']['database'] = 'databasename';
$db['default']['dbdriver'] = 'pdo';

Keeping the pdo_driver.php as default it was spitting out the following error -

Code:
[30-Sep-2013 15:07:35 America/New_York] PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: An invalid keyword 'servername\instancename;dbname' was specified in the DSN string.' in D:\Apache24\htdocs\system\database\drivers\pdo\pdo_driver.php:114
Stack trace:
#0 D:\Apache24\htdocs\system\database\drivers\pdo\pdo_driver.php(114): PDO->__construct('sqlsrv:serverna...', 'user', 'pass', Array)
#1 D:\Apache24\htdocs\system\database\DB_driver.php(115): CI_DB_pdo_driver->db_pconnect()
#2 D:\Apache24\htdocs\system\database\DB.php(148): CI_DB_driver->initialize()
#3 D:\Apache24\htdocs\system\core\Loader.php(346): DB('', NULL)
#4 D:\Apache24\htdocs\system\core\Loader.php(1171): CI_Loader->database()
#5 D:\Apache24\htdocs\system\core\Loader.php(152): CI_Loader->_ci_autoloader()
#6 D:\Apache24\htdocs\system\core\Controller.php(51): CI_Loader->initialize()
#7 D:\Apache24\htdocs\application\controllers\login.php(7): CI_Controller->__construct()
#8 D:\Apache24\htdocs\system\core\CodeIgniter.php(308): Login->__construct()
#9 D:\Apache24\htdocs\index.ph in D:\Apache24\htdocs\system\database\drivers\pdo\pdo_driver.php on line 114

Again, if I edit the actual pdo_driver.php to hardcode the info it's fine, but I shouldn't have to do that. for some reason dbname is not registering out of the database.php file?

I'm using v2.1.4 the PDOs work fine if I don't use codeigniter so it's something internally that's not liking it. Node the "DBNAME" value it's pulling from the pdo_driver.php unless I physically pull that out it does not pull a database name from the database.php file.




Theme © iAndrew 2016 - Forum software by © MyBB