php.net |  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: aidan@php.net Assigned:
Status: Closed Package: PDO related
PHP Version: 6CVS-2005-10-01 (CVS) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: aidan@php.net
New email:
PHP Version: OS:

 

 [2005-10-01 12:24 UTC] aidan@php.net
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-01 12:29 UTC] aidan@php.net
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] wez@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC