PHP Doku:: SQLite - book.sqlite.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenSQLite

Ein Service von Reinhard Neidl - Webprogrammierung.

Anbieterspezifische Datenbankerweiterungen





3 BenutzerBeiträge:
- Beiträge aktualisieren...
25.07.2010 1:12
As of July 2010, there are two ways to use SQLite from PHP:
- procedural: sqlite (=sqlite2), sqlite3
- object-oriented: SQLite3, PDO
Andrew Paul Dickey
12.06.2009 6:43
If you intend to implement 2.x releases of SQLite with your development you are in the right place, as this library is suitable for use with your application (reference

If you intend to use SQLite 3.x releases of SQLite with your development please refer to the section on PHP Data Objects, and specifically the PDO-SQLite implementation available at(references: ,

It is my hope that this post will save both new users and experienced developers time during their initial or a new implementation of PHP & SQLite by encouraging them to use the appropriate libraries.
saivert at saivert dot com
30.04.2008 9:02
How to open a database, create a table if it doesn't exist and inserting initial value.

if ($db = new SQLiteDatabase('filename')) {
$q = @$db->query('SELECT requests FROM tablename WHERE id = 1');
        if (
$q === false) {
$db->queryExec('CREATE TABLE tablename (id int, requests int, PRIMARY KEY (id)); INSERT INTO tablename VALUES (1,1)');
$hits = 1;
        } else {
$result = $q->fetchSingle();
$hits = $result+1;
$db->queryExec("UPDATE tablename SET requests = '$hits' WHERE id = 1");
    } else {

Use this as boilerplate code for any new project using SQLite.

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)