今天开始折腾WP了
要在PHP5里面开启SQLITE支持
extension=php_pdo.dll
extension=php_pdo_sqlite.dll
extension=php_sqlite.dll
否则会报告:
Fatal error: Call to undefined function sqlite_open() in xxx.php on line XX
<?php
print_r(PDO::getAvailableDrivers());
$db=sqlite_open(“db.sqlite”); //打开db.sqlite数据库,如果不存在则尝试创建。
sqlite_query($db,”drop table test”);
sqlite_query($db,”create table test (id INTEGER PRIMARY KEY,name text);”); //创建test表,id字段为自动递增主键
sqlite_query($db,”insert into test (name) values(‘hello’);”); //插入一行内容
sqlite_query($db,”insert into test (name) values(‘world’);”);//插入一行内容
$result=sqlite_query($db,”select * from test”); //取得test表的所有内容
while($row=sqlite_fetch_array($result)) { //通过while循环表中所有内容
print “”;
print_r($row);
print “”;
}
sqlite_close($db);//关闭数据库的连接
?>
输出:
Array ( [0] => mysql [1] => sqlite [2] => sqlite2 ) Array ( [0] => 1 [id] => 1 [1] => hello [name] => hello ) Array ( [0] => 2 [id] => 2 [1] => world [name] => world ) ?>
验证完后,按照 http://wordpress.org/extend/plugins/pdo-for-wordpress/installation/
Step 1: unzip the files in your wp-content directory. After unzipping the structure should look like this
wp-content
->plugins
->themes
->pdo
db.php
index.php[maybe]
The key thing is the presence of the pdo directory and the db.php file in the ‘root’ of the wp-content directory.
Step 2: Edit your wp-config.php file so that:
this line of code is placed directly after the define(‘COLLATE’,”); line:
define(‘DB_TYPE’, ’sqlite’); //mysql or sqlite`
Note: currently only mysql and sqlite are supported. I hope that more flavours will appear soon.
历史博文
- 20090812 KIS2010 WIN2003 - 2009
- 20090813 Wordpress cms BBtheme 修改 - 2009
- 20090812 xml rpc comodo - 2009
- 20090807 Godaddy gegehost - 2009
- 20090807 双飞燕 G7630 电池 - 2009
- 20090807 c# WebBrowser NewWindow2 - 2009
- 20090807 c# Parent Process - 2009
- 20090803 長沙 益阳 印象 - 2009
- 20090803 益阳 丧俗 - 2009
- 20090803 母系 亲戚 外婆 - 2009
试一试评论。
再试一试匿名评论