PHP5, Apache2, Windows 7 and SQLite issues

Connecting to a SQLite3 database and entering one record works fine, but that is where it ends.  Trying to enter two or more records does nothing.  using $db = new SQLite3(‘/database.data’); allows me to only insert one record.  Using $db = new PDO(“sqlite:/database.data”); allows me to insert more than one record.  Therefore, if one is using SQLite3 with PHP 5.3, Apache 2.2, and Windows 7, PDO may work better than SQLite3.  Furthermore, the id INTEGER PRIMARY KEY auto-increments automatically.

NOTE:  PHP 5.3 VC9 is the only version that will work with Windows 7 – 64bit and Apache 2.2.  I tried using both PHP 5.2 VC6 and PHP 5.3 VC6, but they crashed.  Since there is no PHP 5.2 VC9 version, Windows 7 users do not have much of a choice.  Furthermore, extension=php_pdo.dll is not available in the PHP.ini for PHP 5.3.  php_pdo.dll is built into PHP 5.3, so it is not in the PHP.ini.  The instructions can be found at http://php.net/manual/en/pdo.installation.php

If one is doing the SQLite3 tutorials, replacing the $db = new SQLite3 with $db= new PDO may provide more favorable results.

PDO usage from PHP.net.  http://www.php.net/manual/en/class.pdo.php

PDO complete list of commands http://www.php.net/manual/en/book.pdo.php

SQLite datatypes http://www.sqlite.org/datatype3.html

As for what can one do if PDO does not work?  Try the other types such as ODBC.  For the list of other database abstraction layers available in PHP, http://www.php.net/manual/en/refs.database.abstract.php will help.

My PHP function that works with a database can be seen at http://aprivatebeach.com/blog/2000/05/php-open-database/.  Cutting and pasting the code removed all the spaces.  Therefore, the code is badly formatted.

What is PDO, ODBC, and other database abstraction layers?

When one uses databases such as MySQL, SQL Server, Oracle, etc., one will realize that they all have many commands in common.  Furthermore, they all have many commands that are unique to each database.  Therefore the purpose of database abstraction layers is to allow one to access the different databases without the need to know the exact syntax for each and every database.  In other words, one needs to know the generic database commands in order to access any supported database.  The database abstraction layer will do the dirty work of converting the generic database commands into database specific commands.  Unfortunately, with database abstraction layers, one will lose the ability to use database specific commands that are only available in that specific database.

But for the sake of portability and reusability on different databases, losing the database specific features is not a bad thing.  It is easier to change the database from SQLite to MSSQL with generic database commands than to rewrite all the database specific commands to match the syntax required for that specific database.

Leave a Reply