From: gerwin84 at gmail dot com
Operating system: WinXP Pro SP2
PHP version: 5.1.2
PHP Bug Type: PDO related
Bug description: SQLSTATE[] unknown error using MSAccess and write SQL with 0
matching records
Description:
------------
Using the latest PHP windows package (PHP 5.1.3-dev from 19 feb.) PDO
throws an PDOException with message 'SQLSTATE[]: <<Unknown error>>: 0'
when executing an SQL statement (UPDATE or DELETE) where the WHERE
restriction matches zero records in an MSAccess database.
The following ext. are loaded in php.ini:
extension=php_pdo.dll
extension=php_pdo_odbc.dll
Using php-cgi.exe and IIS
Reproduce code:
---------------
/*
Table 'test' description:
field 'user' text(50) | field 'role' text(50)
*/
$situation = 1; //value can be 1 or 2
$DBPath = "d:\\webroot\\database\\pdobug.mdb";
$MSAccessDB = new PDO("odbc:Driver={Microsoft Access Driver
(*.mdb)};Dbq=".$DBPath.";");
$MSAccessDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$SQL1 = "INSERT INTO test VALUES( 'testuser','testrole');";
$SQL2 = "UPDATE test SET role='administrator' WHERE user='testuser' AND
role='testrole';";
$SQL3 = "DELETE FROM test WHERE user='testuser';";
$MSAccessDB->exec($SQL1);
switch($situation){
case 1:
$MSAccessDB->exec($SQL2); //ok
$MSAccessDB->exec($SQL2); //error
break;
case 2:
$MSAccessDB->exec($SQL3); //ok
$MSAccessDB->exec($SQL3); //error
break;
}
Expected result:
----------------
a blank page as output and changes to the database log:
- Always first a new row added.
- In situation 1: the new row changed.
- In situation 2: the new row deleted.
Actual result:
--------------
This is the error in in situation 1:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[]:
<<Unknown error>>: 0 (SQLExecDirect[0] at
ext\pdo_odbc\odbc_driver.c:230)' in D:\webroot\www\test\pdobug.php:20
Stack trace:
#0 D:\webroot\www\test\pdobug.php(20): PDO->exec('UPDATE test SET...')
#1 {main}
thrown in D:\webroot\www\test\pdobug.php on line 20
The error in situation 2 is exacly the same, except line numbers etc. of
course.
--
Edit bug report at http://bugs.php.net/?id=36632&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36632&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36632&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36632&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36632&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36632&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36632&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36632&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36632&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36632&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36632&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36632&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36632&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36632&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36632&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36632&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36632&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36632&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36632&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36632&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36632&r=mysqlcfg