As many of you did, I upgraded from Lucid to Precise this week and almost everything seems to work find.
everything except… SQLite, which was working well before but not anymore.
I checked everything: phpinfo(), php.ini, sqlite3.ini.
The sqlite
command works fine, but when I try to use PHP... *PLOP*, nothing works.
I get the message
Fatal error: Class 'SQLiteDatabase' not found in /var/www/test/sqlite/index.php on line 4
Line 4 being
$db = new SQLiteDatabase('test.sqlite', 0666);
Any hint?
edit
You can see my phpinfo() here: http://pastebin.com/jQ7Bz0GN
The apache log is
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
Extensions
According to Vendor Specific Database Extensions page on the PHP site, there are two SQLite extensions:
SQLite3 extension is a newer replacement of SQLite, which soon will become obsolete:
Ubuntu 10.04 vs 12.04
Now, some practicalities. Let's have a look at default web server configuration that was installed using:
Ubuntu 10.04:
Ubuntu 12.04:
So, Ubuntu 12.04 default PHP installation (as of writing this - version 5.3.10) already does not have
sqlite
extension as built in. The output above states that onlysqlite3
extension is present, which came fromphp5-sqlite
package.Solution
Pick your evil:
Following Andrejs Cainikovs' answer and strongly advising you to upgrade the code, here some examples of what kind of work should be done, when migrating from
SQLiteDatabase
class (sqlite library) toSQLite3
class (SQLite3 library).For example:
SQLiteDatabase
->SQLite3
,SQLiteDatabase::unbufferedQuery
->SQLite3::query
,SQLiteResult::fetchAll(SQLITE_*)
->SQLite3Result::fetchArray(SQLITE3_*)
etc.As for fetching, in old SQLite we had:
While, in new SQLite3 we should:
Other changes requires similar amount of work, so this shouldn't be a life-time process.
Before you begin, you have to first use a tool like SQLite Studio to convert your database file from 2.1 to 3.0. Size can be lowered by even a half, so I think it is something worth fighting for.
Solution (NOT for production, just for play):
1. Get "php5-sqlite" deb file from ubuntu11.04 or any other
2. Extract it and find file sqlite.so
-- You can get sqlite.so in other way, for example from Your old system --
3. Put sqlite.so to /usr/lib/php5/20090626+lfs/
4. Add this to php.ini (/etc/php5/apache2/php.ini):