ID: 34699
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: PDO related
Operating System: Linux
PHP Version: 6CVS-2005-10-01 (CVS)
New Comment:
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 :)
Previous Comments:
------------------------------------------------------------------------
[2005-10-01 12:29:03] [EMAIL PROTECTED]
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-01 12:24:47] [EMAIL PROTECTED]
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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34699&edit=1