|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-10-01 12:29 UTC] aidan@php.net
[2005-10-02 22:36 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Description: ------------ In PHP6, PDO seems unable to write to a sqlite database. However, just to make it interesting, it's only a problem when the script is executed by the webserver (in my case apache). Initially I thought it was a permissions issue, but the database file was 666. Running the script from CLI worked as expected, running it from the webserver produced the error: Warning: PDO::query() [function.query]: SQLSTATE[HY000]: General error: 1 unable to open database file Confusing, because the database file is already open as demonstrated by the successful query of the same table in the previous line. Reproduce code: --------------- <?php $db = new PDO('sqlite:repository.db'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $res = $db->query('SELECT visits from pages where id=1'); $tml = $res->fetchAll(); echo $tml[0][0], "\n"; $db->query('UPDATE pages SET visits = visits+1 WHERE id =1'); Expected result: ---------------- 23324 Actual result: -------------- 23324 Warning: PDO::query() [function.query]: SQLSTATE[HY000]: General error: 1 unable to open database file in /home/aidan/public_html/repos/database/test.php on line 10