22
0
Fork 0

Amélioration exemple PHP

This commit is contained in:
Ludovic Poujol 2018-05-22 15:07:00 +02:00
parent 2ad0eaab2f
commit bbb3876c4e
1 changed files with 19 additions and 5 deletions

View File

@ -60,13 +60,27 @@ sqlite> DROP TABLE foo;
## PHP et SQLite
* <http://php.net/manual/fr/book.sqlite.php>
Assurez vous d'avoir l'extension sqlite3 installée et active.
Sur un système Debian `apt install php-sqlite3` récupérera l'extension si elle n'est pas déjà présente.
* <http://php.net/manual/fr/book.sqlite3.php>
~~~
$db = sqlite_open('foo.db');
sqlite_query($db,'CREATE TABLE foo (i int)');
sqlite_query($db,"INSERT INTO foo VALUES (42)");
$result = sqlite_query($db,'select * from foo');
$db = new SQLite3('foo.db');
$db->exec('CREATE TABLE foo (i int)');
$db->exec('INSERT INTO foo VALUES (42)');
$result = $db->query('select * from foo');
~~~
Il est aussi possible de manipuler une base SQLite avec PDO
~~~
try{
$pdo = new PDO('sqlite:foo.db');
} catch (PDOException $e){
exit('PDO Error');
}
~~~