try {
//建立連線
$dbh = new PDO('sqlite:./test.db3');
//建表格
$dbh->exec("CREATE TABLE a(id integer,name varchar(255))");
//增加資料
$dbh->exec("INSERT INTO a values(1,'test')");
$dbh->beginTransaction();
//取得資料
$sth = $dbh->prepare('SELECT * FROM a');
$sth->execute();
//獲取結果
$result = $sth->fetchAll();
print_r($result);
}
catch (PDOException $e)
{ echo 'Connection failed: ' . $e->getMessage(); }
if(isset($dsn)) $dsn=null;
沒有留言:
張貼留言