#40935 [NEW]: Error/Exception with PDO::fetch/fetchAll and disabled ATTR_EMULATE_PREPARES
| From: | phpbugs at filofox dot com | Date: | Wed, 28 Mar 2007 13:28:59 +0000 |
| Subject: | #40935 [NEW]: Error/Exception with PDO::fetch/fetchAll and disabled ATTR_EMULATE_PREPARES | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-110879@lists.php.net to get a copy of this message | ||
From: phpbugs at filofox dot com
Operating system: Linux Debian Sarge 3.1
PHP version: 5.2.1
PHP Bug Type: PDO related
Bug description: Error/Exception with PDO::fetch/fetchAll and disabled ATTR_EMULATE_PREPARES
Description:
------------
When using PDO with MySQL, if ATTR_EMULATE_PREPARES is disabled, an
exception (or error if not using ERRMODE_EXCEPTION) is thrown if you try to
fetch() or fetchAll() a null result set (i.e. after INSERT, UPDATE etc.).
However, if ATTR_EMULATE_PREPARES is enabled, the exception/error is not
triggered.
Clearly fetch on a null result set is redundant, but either it should
throw an exception/error or it shouldn't, regardless of the state of
ATTR_EMULATE_PREPARES.
Reproduce code:
---------------
$db = new PDO( $dsn, $username, $password );
// enables exceptions
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
// disable emulation <--- this triggers the problem
$db->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
$sql = 'INSERT INTO TestTable VALUES ( NULL )';
$query = $db->prepare( $sql );
if( $query->execute() )
{
$results = $query->fetchAll( PDO::FETCH_ASSOC );
}
$query->closeCursor();
Expected result:
----------------
Either an exception/error should be thrown in both cases, or neither.
Actual result:
--------------
'PDOException' :: 'SQLSTATE[HY000]: General error: 2053 '
--
Edit bug report at http://bugs.php.net/?id=40935&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40935&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40935&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40935&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40935&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40935&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40935&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40935&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40935&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40935&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40935&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40935&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40935&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40935&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40935&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40935&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40935&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40935&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40935&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40935&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40935&r=mysqlcfg