PHP5已经绑定sqlite
1、手动添加的php的pdo的驱动扩展支持 ,在PHP.ini添加
[PHP_SQLITE]
extension=php_sqlite.dll
extension=php_pdo.dll
extension=php_pdo_sqlite.dll
extension_dir = "C:\Program Files\Apache Group\php5\ext"
2、在C:\Program Files\Apache Group\php5\ext保证有php_sqlite.dll,php_pdo_sqlite.dll,
php_pdo.dll扩展库
3、重启apache
4、下载SQLitemanager,create a database,保存名“db.sqlite”的数据库,建表,
或者sqliteadmin
5、在PHP链接SQLite
方法一、$db= new PDO('sqlite:db.sqlite') ;
print_r($db);
$sth = $db->query("select * from aqo");
方法二、if ($db = sqlite_open('db.db', 0666, $sqliteerror)) {
sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))');
sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
$result = sqlite_query($db, 'select bar from foo');
var_dump(sqlite_fetch_array($result));
} else {
die($sqliteerror);
}
6、新建一个sqlite.php文件,判断下服务器是否支持sqlite,判断函数是:extension_loaded(‘sqlite’),支持时返回TRUE,不支持返回FALSE
例子:
<?php
if (extension_loaded(‘sqlite’)) {
echo ‘支持sqlite’;
}else{
echo ‘不支持sqlite’;
}
?>
|