本文共 1070 字,大约阅读时间需要 3 分钟。
I spent half a day trying to work out why I could not update my sqlite3 database from apache using the PHP PDO driver. I was getting NO error messages at all.
I could connect and select data, but not modify it.
It wasn't until I added the following line:
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
after immediately opening the database, that I got a hint of what was happening.
filename: File3
dl_count: 100
( ! ) Warning: PDO::exec() [pdo.exec.html]: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /www/htdocs/test/dl-counter/sqlite-readwrite-test.php on line 76
Call Stack
#
Time
Memory
Function
Location
1 0.0086 330120 {main}( ) ../sqlite-readwrite-test.php:0
2 0.0273 331240 PDO->exec( ) ../sqlite-readwrite-test.php:76
Affected Rows: ''
filename: File3
dl_count: 100
The problem was with the file permissions. As root I could read and write the database from the sqlite3 command line monitor. But Apache was unable to write the database.
Changed the permissions to 755 wwwrun:wwrun and it all works OK!
Thanks again :)
转载地址:http://yjima.baihongyu.com/