php.net |  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: None
 [2006-03-06 17:12 UTC] gerwin84 at gmail dot com
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-21 04:10 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-04-21 14:17 UTC] gerwin84 at gmail dot com
With the latest windows version,
5.1.3RC4-dev 
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] wez@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fix will be in PHP 5.1.4
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC