在内存中创建 SQLite 数据库
尝试了解一些有关 PDO 的知识,并正在阅读本教程。它具有以下代码片段:
<?php
try
{
$db = new PDO('sqlite::memory');
echo "SQLite created in memory.";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
当我运行此代码时,我收到以下异常消息:
SQLSTATE[HY000] [14] 无法打开数据库文件
是什么意思?我怎样才能让它发挥作用?我能够连接到 MySQL 数据库以及常规 SQLite 数据库文件。所以我知道至少有一些东西正在工作......
我使用的是 Windows 7 64 位,带有 Apache 2.2.11 和 PHP 5.3.0(最新的 WampServer 安装)。 phpinfo()
报告我启用了启用了 SQLite 库 3.6.15 的 pdo_sqlite。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须编写
缺少尾随
:
的内容。文档
You have to write
the trailing
:
is missing.Documentation
不确定 @ win 权限,但在 *nix 上,SQLite 需要对临时文件的数据库文件目录进行写入权限。
Not sure @ win permissions, but on *nix, SQLite needs write permision to the dir confining database files for temp files.