Site Tools


Hotfix release available: 2025-05-14b "Librarian". upgrade now! [56.2] (what's this?)
Hotfix release available: 2025-05-14a "Librarian". upgrade now! [56.1] (what's this?)
New release available: 2025-05-14 "Librarian". upgrade now! [56] (what's this?)
prog:php:samples:sqlite
<?php
 
try {
    $db = new PDO('sqlite:rene_pictures.sqlite');
 
    $db->exec("CREATE TABLE picture (id INTEGER, name TEXT)");
    $db->exec("CREATE UNIQUE INDEX idx_picture_id ON picture (id)");
    $db->exec("CREATE INDEX idx_picture_name_id ON picture (name)");
 
 
    $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
 
    $res = $db->query("INSERT INTO picture (name, timestamp) VALUES ('test pilt 1', 12341234)");
    $res = $db->query("INSERT INTO picture (name, timestamp) VALUES ('test pilt 2', 12341234)");
    $res = $db->query("INSERT INTO picture (name, timestamp) VALUES ('test pilt 3', 12341234)");
 
    $res = $db->query("SELECT * FROM picture");
    foreach($res->fetchAll() AS $row) {
        print_r($row);
    }
 
    $db = NULL;
}
catch(PDOException $e) {
    print 'Exception : '.$e->getMessage();
}
prog/php/samples/sqlite.txt · Last modified: 2019/09/20 15:52 by 127.0.0.1