n/oldblog
Archived
1
0
Fork 0
This repository has been archived on 2024-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
oldblog/sqlite.php

30 lines
706 B
PHP
Raw Normal View History

2023-04-30 21:28:42 +02:00
<?php
echo "coucou";
// create new database (OO interface)
$db = new SQLiteDatabase("db.sqlite");
// create table foo and insert sample data
$db->query("BEGIN;
CREATE TABLE foo(id INTEGER PRIMARY KEY, name CHAR(255));
INSERT INTO foo (name) VALUES('Ilia');
INSERT INTO foo (name) VALUES('Ilia2');
INSERT INTO foo (name) VALUES('Ilia3');
COMMIT;");
// execute a query
$result = $db->query("SELECT * FROM foo");
// iterate through the retrieved rows
while ($result->valid()) {
// fetch current row
$row = $result->current();
print_r($row);
// proceed to next row
$result->next();
}
// not generally needed as PHP will destroy the connection
unset($db);
?>