UTF-8
UTF-8

Reputation: 625

Add SqLite to PHP5

I'm using Ubuntu 14.04 64 bit and installed the php5 package from the repositories which brought Apache with it. Php itself works but when I try to use new SQLiteDatabase([...]), the error

Fatal error: Class 'SQLiteDatabase' not found in [...] on line [...]

is printed.

The php.ini in use is /etc/php5/apache2/php.ini (according to phpinfo() (link to the website it prints)). I noticed that in the php.ini the block

[sqlite]
; http://php.net/sqlite.assoc-case
;sqlite.assoc_case = 0

[sqlite3]
;sqlite3.extension_dir =

doesn't set an extension directory. I tried finding files called sqlite3 on my system and putting a path to their directories in there, but it didn't work (and I restarted my machine after changing the php.ini).

The package php5-sqlite3 doesn't exist for Ubuntu 14.04 but php5-sqlite does and I installed it before trying anything else. I then also installed the packages sqlite3 and sqlite, but again: I doesn't work.

Upvotes: 0

Views: 651

Answers (1)

Sergio Ivanuzzo
Sergio Ivanuzzo

Reputation: 1922

I have found a solution. So, according to http://stevenclark.info/wp/fatal-error-class-sqlitedatabase-not-found-in/

As of PHP 5.4 the SQLiteDatabase class was removed to make way for SQLite 3.

So, you need to use this:

$db=new SQLite3("db.sqlite");

Upvotes: 1

Related Questions