php访问sqlite数据库的例子,学习下sqlite_query、sqlite_fetch_array函数的用法访问sqlite数据库(Access sqlite database)<?php
$dbconn = sqlite_open('phpdb');
if ($dbconn) {
sqlite_query($dbconn, "CREATE TABLE animal(Name VARCHAR(255), MaxAge INT);");
sqlite_query($dbconn, "INSERT INTO animal VALUES ('A', 15)");
$result = sqlite_query($dbconn, "SELECT Name FROM animal");
var_dump(sqlite_fetch_array($result, SQLITE_ASSOC));
} else {
print "Connection to database failed!\n";
}将结果集保存到数组中<?php
$rows = array();
while ($row = sqlite_fetch_array($result, $res_type, $decode)) {
$rows[] = $row;
}
?>