|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36632 SQLSTATE[] unknown error using MSAccess and write SQL with 0 matching records
Submitted: 2006-03-06 17:12 UTC Modified: 2006-04-30 01:27 UTC
From: gerwin84 at gmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.1.3RC4-dev OS: WinXP Pro SP2
Private report: No CVE-ID:
 [2006-03-06 17:12 UTC] gerwin84 at gmail dot com
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:

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.";");

$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';";

	case 1:
		$MSAccessDB->exec($SQL2); //ok
		$MSAccessDB->exec($SQL2); //error
	case 2:
		$MSAccessDB->exec($SQL3); //ok
		$MSAccessDB->exec($SQL3); //error

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-21 04:10 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-04-21 14:17 UTC] gerwin84 at gmail dot com
With the latest windows version,
Build Date Apr 21 2006 12:14:54,
it is still not working.
Exactly the same problem, with no differences.
 [2006-04-30 01:27 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Fix will be in PHP 5.1.4
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 18:01:32 2015 UTC