简单的用PHP连接SQLite建立表,并使用INSERT和SELECT语句操作SQLITE数据库。
<?php
if ( $db = sqlite_open('./xz.db',0666,$sqliteerror) ){
$desc = "create table user(id integer primary key,nametext);";
sqlite_query($db, $desc);
$sql = "insert into user values(NULL, 'xiaozhe')";
$res = sqlite_query($db, $sql);
$sql1 = "select * from user";
$res = sqlite_unbuffered_query($db, $sql1);
while ($item = sqlite_fetch_array($res, SQLITE_ASSOC)) {
print "ID:".$item["id"] ."NAME:".$item["name"];
print "<BR>";
}
sqlite_close($db);
}else{
print $sqliteerror;
}
?>