$db = new SQLite3('database.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
<?php class Database extends SQLite3 { function __construct() { $this->open('database.db'); } } $db = new Database(); $db->exec('create table dolgok (valami string); $db->exec("insert into dolgok (valami) values ('Teszt dolog')"); $result = $db->query('select valami from dolgok'); var_dump($result->fetchArray()); $db->close();
<?php $db = new SQLite3(':memory:'); $db->exec('create table dolgok (vmi TEXT)'); $stmt = $db->prepare('insert into dolgok values (:vmi)'; $stmt->bindParam(':vmi', $vmi, SQLITE3_TEXT); $vmi = 'Valami'; $stmt->execute(); $vmi = 'Más'; $stmt->execute(); $res = $db->query('select * from dolgok'); while(($row = $res->fetchArray(SQLITE3_ASSOC))) { var_dump($row); }