|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34699 PDO's sqlite driver unable to write to database
Submitted: 2005-10-01 12:24 UTC Modified: 2005-10-02 22:36 UTC
From: Assigned:
Status: Closed Package: PDO related
PHP Version: 6CVS-2005-10-01 (CVS) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2005-10-01 12:24 UTC]
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:
$db = new PDO('sqlite:repository.db');

$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:

Actual result:
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-01 12:29 UTC]
Ah, it is a permissions issue. The directory must have write permissions too.

I'll add this as a note into the docs, and close the bug.

Perhaps it would be possible Wez, for the sqlite driver to give a more specific error?
 [2005-10-02 22:36 UTC]
The PDO driver has no more of an idea of the cause than you do; it's passing back the error information from sqlite.  You're better off asking the sqlite guys to make their error messages a bit more human friendly :)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 10:03:36 2021 UTC