Home > php教程 > php手册 > php下使用PDO创建sqlite3数据库

php下使用PDO创建sqlite3数据库

WBOY
Release: 2016-06-13 10:50:11
Original
1077 people have browsed it

错误1:
1 Uncaught exception 'PDOException' with message 'could not find driver
1.打开php.ini文件
1 extension=php_pdo.dll
同时去掉
1 extension=php_pdo_sqlite.dll
2.重启apache服务
3.编写测试代码

01  02 echo "creating a databse \n";
03 try {
04     $dbh=new PDO('sqlite:voting.db');
05     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
06     $dbh->exec('
07     CREATE TABLE tally(
08     QID varchar(32) NOT NULL,
09     AID integer NOT NULL,
10     votes integer NOT NULL,
11     PRIMARY KEY(QID,AID)
12     )');
13     www.2cto.com
14     
15 } catch (Exception $e) {
16     echo "error!!:$e";
17     exit;
18     
19 }
20 echo "db created successfully!";
21 ?>
4.成功!


作者:jeffsui
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template