3

Does someone has or know a php class to easily use SQLite3 on PHP?

I has been using this one http://code.jenseng.com/db/ but it's for sqlite2 dbs.

I used it to execute queries and fetch arrays of results, I've found one but its a huge code, I was looking for something simpler.

3 Answers 3

11

PHP has a native SQLite3 class, which is enabled by default as of PHP 5.3.0

Example from PHP Manual

$db = new SQLite3('mysqlitedb.db');
$db->exec('CREATE TABLE foo (bar STRING)');
$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')");
$result = $db->query('SELECT bar FROM foo');
var_dump($result->fetchArray());
Sign up to request clarification or add additional context in comments.

1 Comment

The debian 8 package version of php PHP 5.6.20-0+deb8u1 (cli) (built: Apr 27 2016 11:26:05) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies comes without sqlite and have to be installed via apt-get install php5-sqlite
4

you should be able to do so with the PDO class (Cross DBMS).

Comments

0

You can achieve the same using PDO:

http://www.php.net/PDO

See the examples and comments for fetchAll()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.