Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use and access an SQLite DB using PHP and Wamp Server?

I know PHP 5 already supports SQLite but for some reason I can't get it to work.

I followed the instructions from SQLite tutorial: Getting started. I also made sure that the following are not commented out from php.ini:

extension=php_pdo_sqlite.dll 
extension=php_sqlite.dll.

But when I open the PHP file from localhost using Firefox, I get this error:

Fatal error: Class 'SQLiteDatabase' not found.

I'm on Windows by the way, if that info matters.

What may be the cause of this problem?

like image 733
Jarvis Avatar asked Jul 07 '09 09:07

Jarvis


2 Answers

I think the class SQLiteDatabase is from the extension sqlite rather pdo_sqlite. So you could enable the sqlite extension, or use PDO instead:

<?php
$conn = new PDO('sqlite:c:/mydb.sq3');
$conn->exec('some sql query');
like image 83
Tom Haigh Avatar answered Oct 09 '22 11:10

Tom Haigh


On Windows you need to have the following set in your ini:

extension=php_pdo.dll
extension=php_sqlite.dll

I recommend you read this page in the manual.

like image 37
Kieran Hall Avatar answered Oct 09 '22 11:10

Kieran Hall