Page 1 of 1

Activating SQLite3 in XAMPP

PostPosted: 04. April 2009 18:33
by mokogobo
Hello. I would like to use SQLite3 with XAMPP, but am having difficulties enabling it. SQLite2 is active, even regardless of which SQLite extensions I uncomment in the php.ini and php5.ini files.

Again, I'd like to use SQLite3 with XAMPP on Windows. Can anyone point me in the right direction or suggest anything to try?

Thanks.

Re: Activating SQLite3 in XAMPP

PostPosted: 04. April 2009 19:21
by Wiedmann
I would like to use SQLite3 with XAMPP

SQLite3 is available through the pdo_sqlite extension.

Re: Activating SQLite3 in XAMPP

PostPosted: 26. April 2009 02:20
by sysdev
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