While trying out SQLMaestro’s Sqlite PHP generator I made the startling discovery that when PHP5 talks about embedded SQLite support, the SQLite in question is the old version 2 format rather than SQLite3. I know, I know, if you use PDO (the new JDBC/ODBC like OO method of accessing databases) you can use either V2 or V3, but the traditional method of accessing databases in PHP is via database specific function calls (e.g. sqlite_open, mysqli_connect) and again I know it’s not the “modern way” of doing things but it’s “good enough” and it’s the accepted PHP way of doing things (e.g. it’s the method used by SQLMaestro’s various PHP generators).

I can understand the reasoning behind keeping the sqlite_ functions backward compatible (the newer sqlite3 file structure is not compatible with v2, you’ll get a “file is encrypted or is not a database” error if you attempt to open a v3 database using v2), but why not build in a sqlite3_ set of functions (in the same way there are mysql_ and mysqli_ versions).

There is a sourceforge project PHP-SQLite3 attempting to add this functionality but it’s at “alpha-quality” stage (you have to PHPize the .so from source and I have no idea how to build the windows .dll extension) and doesn’t appear to yet support all the sqlite_ equivalent functions.

It is 3 years since Sqlite3 was released and I would think that the vast majority of SQLite adopters have started using it since that date and to them the only SQLite is SQLite3.


One response to “PHP5 and SQLITE3

  1. Pingback: Python the new VBA ? « Gobán Saor