Activating SQLite3 in XAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Activating SQLite3 in XAMPP

Postby mokogobo » 04. April 2009 18:33

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.
mokogobo
 
Posts: 1
Joined: 04. April 2009 18:29

Re: Activating SQLite3 in XAMPP

Postby Wiedmann » 04. April 2009 19:21

I would like to use SQLite3 with XAMPP

SQLite3 is available through the pdo_sqlite extension.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Activating SQLite3 in XAMPP

Postby sysdev » 26. April 2009 02:20

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
sysdev
 
Posts: 1
Joined: 26. April 2009 01:35


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 219 guests