• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug in PDO driver class?

I tried using the new PDO driver that is included with CI 2.1.0. It didn't go well. It was unable to create a connection. I think I tracked down the problem and fixed it, but I never like adding (or removing) anything from the core.
The problem seemed to be when instantiating a new PDO instance. On line 114 of pro_driver.php we have:
return new PDO($this->hostname, $this->username, $this->password, $this->options);
The problem is that
is incorrect. In my case this is currently just localhost.
Currently it is set on line 81:
$this->hostname .= ";dbname=".$this->database;
The problem is that it is missing the first bit of the string that PDO needs. Immediately before line 81 I have added
$this->hostname = 'mysql:host='.$this->hostname;
This builds the correct string and I can now connect as expected. Of course the problem with this fix is that I've hardcoded mysql...

I think that this is a better solution, edit the database config file in:


configure the hostname like this:

$db['default']['hostname'] = 'mysql:host=localhost';

It is working fine for me.

Maybe this is the expected way of working with it, the UserGuide is still outdated,
I think they are working on it.

Sorry for my poor english.

There has been a LOT of work on the PDO driver on github in the last month or so which will be in the next release. You can try the PDO drivers from there and see if it helps.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.