【PHP】Sqlite3


網路都找到的一些都有一點小問題 整理後的範例

$dsn = 'sqlite:sql.db';
try{
    $dbh = new PDO($dsn, $user, $password);
    echo 'PDO Connection Ok',"\n";
    $dbh->exec("CREATE TABLE PKU(id integer,name varchar(255))");
    echo 'Create Table ok',"\n";
    $dbh->exec("INSERT INTO PKU values(1,'jarjin')");
    echo 'Insert Data ok',"\n";
    $dbh->beginTransaction();
    $sth = $dbh->prepare('SELECT *FROM PKU');
    $sth->execute();
    $result = $sth->fetchAll();
    print_r($result);
    $dsn=null;
    } catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
        $dsn=null;
    }

參考 sqlite php5 PDO

 

Ed32. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com