PHP SQLite – Why Class ‘SQLiteDatabase’ is Not Found in /var/www/*.php

PHPsqlite

I am trying to use sqlite from PHP. I have the following simple code:

<?php
$db = new SQLiteDatabase("test2.sdb");
unset($db);
?>

As the result of this code (which I execute in the command line "php test2.php") I get:

Fatal error: Class 'SQLiteDatabase' not found in /var/www/test2.php on line 3

Does anybody know how can I make PHP able to use sqlite?

P.S.
Here I found out that "SQLite support is enabled by default on a standard Linux PHP compilation starting with PHP 5.0." And I have "PHP Version => 5.2.6-2ubuntu4.6". So, sqlite should be enabled unless the "–disable-sqlite". In my case output of "phpinfo();" does not contain "sqlite" at all.

Best Answer

There's quite a few reports of the same issue out on Google but no definitive solution.

Double-check your SQLlite extension is enabled in PHP, and you should be able to use the sqlite_* family of functions (such as sqlite_open) instead of the OOP approach, not ideal I know.

Also just check that your PECL module for sqlite is >= 1.0.0.

Related Topic