Welcome Guest, Not a member yet? Register   Sign In
PDO SQLite Driver not connecting
#1

[eluser]QuantumHive[/eluser]
Hi,
I'm trying to use PDO to connect to a SQLite Database.
Using Apache2.4 on Windows 7 with PHP 5.4.13 (pdo and sqlite extensions are enabled in php.ini. See this screenshot: http://puu.sh/2xtEF.jpg)

I'm getting this error:
Quote:PHP Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

Database configs are:
Code:
$db['default']['hostname'] = '';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = 'sqlite:c:/Apache24/htdocs/prac3/application/db/database3.sqlite';
$db['default']['dbdriver'] = 'pdo';

When debugging I found that the error was caused in the function dp_pconnect() in the file pdo_driver.php.
The PDO constructor is called like this:
Code:
new PDO (";dbname=sqlite:c:/Apache24/htdocs/prac3/application/db/database3.sqlite", "", "", ...);
After this it throws that error.

Now, I tried to test this by calling my own PDO connection without the ;dbname= part:
Code:
new PDO ("sqlite:c:/Apache24/htdocs/prac3/application/db/database3.sqlite", "", "", ...);
This does not throw me an error. Also this is how it is documented here: http://www.php.net/manual/en/ref.pdo-sql...ection.php

So what's going on here? Is this a bug or am I doing something wrong?
#2

[eluser]TheFuzzy0ne[/eluser]
I'm pretty sure your DSN string needs to go into $db['default']['hostname'].
#3

[eluser]QuantumHive[/eluser]
Code:
$db[‘default’][‘hotstname’] = "sqlite:path/to/file.sqlite"
?
Then what should $db['default']['database'] be?
#4

[eluser]TheFuzzy0ne[/eluser]
I'm pretty sure you'd leave that empty, since the file itself is the database, and you specify that in your DSN string.

I might be wrong. Someone please correct me if I am.
#5

[eluser]QuantumHive[/eluser]
Thanks, it all worked out.




Theme © iAndrew 2016 - Forum software by © MyBB