Welcome Guest, Not a member yet? Register   Sign In
Problem with pdo_driver on 2.1.3
#1

[eluser]Unknown[/eluser]
I've just installed CI for the first time and much to my disappointment the tutorial doesn't work. I got as far as the Tutorial − News page, the part where you add a database into the site. I'm using PHP 5.3.13, IIS and SQL Server 2005; I have the pdo_sqlsrv and sqlsrv php drivers enabled. I tried both the sqlsrv and pdo dbdriver and got failures with both. I decided to troubleshoot the pdo connection as we use this in other applications.

I traced the problem to the pdo_driver.php file. The driver incorrectly assembles the DSN string.

I had to specify the host name like this (in database.php):
//$db['default']['hostname'] = 'servername.domain.com'; // CI code
$db['default']['hostname'] = 'sqlsrv:Server=servername.domain.com';

and had to add code to the pdo_driver like this (around line 81):
//empty($this->database) OR $this->hostname .= ';dbname='.$this->database; //CI code
if (strstr($this->hostname, 'sqlsrv') == TRUE){
$this->hostname .= ";Database=".$this->database;
}
else
{
$this->hostname .= ";dbname=".$this->database;
}

The driver needs to be repaired so that a future update does not completely crash my site.
#2

[eluser]Aken[/eluser]
3.0 has better DSN support for the PDO library. You should try it out if you have time to confirm. https://github.com/EllisLab/CodeIgniter




Theme © iAndrew 2016 - Forum software by © MyBB