I experience some troubles in getting XAMPP PHP to work with sqlite3, and now have it working as follows...
I have XAMPP version 1.7.0
I modify the php.ini file located here:
<xampp-base-dir>/apache/bin/php.ini
- Code: Select all
extension=php_pdo_sqlite.dll ; this line is uncommented
and restart the Apache service and SQLite3 works with PDO.
There are several other PHP ini files, for example:
<xampp-base-dir>/php/php.ini
<xampp-base-dir>/php/php5.ini
these are just copies, and do not control PHP for XAMPP apache.
Calling phpinfo(); from PHP displays the PHP config, and the PHP PDO configuration:
PDO drivers mssql, mysql, sqlite, sqlite2
note that
sqlite displays. To be clear, this driver allows sqlite3 databases to be used in PHP through PDO like this:
- Code: Select all
<?php
try {
$dbh = new PDO('sqlite:C:/projects/my-sqlite-database.db');
$sth = $dbh->prepare("SELECT * FROM accounts");
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
print_r($result);
print("\n");
$dbh = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
The line of PHP code shown above is correct to access sqlite3 databases:
- Code: Select all
$dbh = new PDO('sqlite:C:/projects/my-sqlite-database.db');
Note that the driver specifier is
sqlite -- it's what you want to use PDO for sqlite3 databases.
I am using sqlite 3.6.13 in my project and with the above settings and example code can use the sqlite3 database now.
Here is the link to an answer that helped me get this working:
http://groups.google.com/group/comp.lan ... e31eb8a689