【发布时间】:2015-07-18 18:02:24
【问题描述】:
我在 Linux 环境中使用 PHP 没问题,但我正在开发一个 PHP 应用程序,该应用程序在 Windows Server 2012 R2 上的 IIS 8 上使用 PDO 的 sqlite。
从数据库中读取工作正常;尝试插入或更新会导致相当无用的错误,“无法打开数据库文件”
运行良好的代码:
if (!($db = new PDO('sqlite:assets/database.db'))) { ?>
...
} else {
$stmt="SELECT
... ";
$stmt = $db->prepare($stmt);
$stmt->execute(array(":person" => $this->uid));
}
不起作用的代码:
if (!($db = new PDO('sqlite:assets/database.db'))) { ?>
...
} else {
$stmt = "INSERT INTO bills(date, label, categ, amount, timestamp) VALUES(?, ?, ?, ?, ?)";
$stmt = $db->prepare($stmt);
var_dump($stmt->errorInfo());
// yields : array(3) { [0]=> string(0) "" [1]=> NULL [2]=> NULL }
$stmt->execute([$fData['date'], $fData['label'], $fData['categ'], $fData['amount'], $fData['timestamp']]);
var_dump($stmt->errorInfo());
// yields : array(3) { [0]=> string(5) "HY000" [1]=> int(14) [2]=> string(28) "unable to open database file" }
}
我已经尝试过的事情:
- 确保 IIS 用户具有数据库文件的读/写权限,per this question
- 确保 IIS 用户对包含数据库文件的目录具有读/写权限。 per this question
- 检查 IIS 错误日志以了解发生了什么。 (唯一存在的是由于此请求失败而导致的不相关警告。)
- 确保它适用于另一个数据库(它适用于 mySQL,但 sqlite 是最终应用程序的硬性要求。)
非常感谢任何帮助!
【问题讨论】: