简体   繁体   English

Phar存档中的SQLite数据库

[英]SQLite database inside Phar archive

I'm trying to access SQLite database through PDO extension inside Phar archive, but I'm getting error: 我正在尝试通过Phar存档中的PDO扩展访问SQLite数据库,但我收到错误:

exception 'PDOException' with message 'SQLSTATE[HY000] [14] unable to open database file' 异常'PDOException',消息'SQLSTATE [HY000] [14]无法打开数据库文件'

PHP manual says it's possible to modify files inside archive. PHP手册说可以修改存档中的文件。 How can I fix it? 我该如何解决?

After some research, I realized, that problem can be solved by a little hack. 经过一番研究,我意识到,这个问题可以通过一点点破解来解决。

  1. Copy database file to system's temporary directory 将数据库文件复制到系统的临时目录
  2. Connect PDO to database copy and do your operations 将PDO连接到数据库副本并执行操作
  3. Overwrite original database file with modified copy. 使用修改后的副本覆盖原始数据库文件。

Not very reliable solution - you need to be careful about unhandled errors or exceptions, because you may lose your changes. 不是非常可靠的解决方案 - 您需要注意未处理的错误或异常,因为您可能会丢失更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM