#36578 [Opn]: $stmt->fetch() on empty resultset does nothing

From: Date: Wed, 01 Mar 2006 19:01:40 +0000
Subject: #36578 [Opn]: $stmt->fetch() on empty resultset does nothing
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93814@lists.php.net to get a copy of this message
ID: 36578 User updated by: terry at bitsoup dot com Reported By: terry at bitsoup dot com Status: Open Bug Type: PDO related Operating System: Windows XP PHP Version: 5.1.2 New Comment: Sorry, error code should be 02, not 20 Previous Comments: ------------------------------------------------------------------------ [2006-03-01 19:59:35] terry at bitsoup dot com Description: ------------ A fetch against a statment that returns an empty resultset doesn't set any PDO error information, nor does it raise an exception. Testing against MySQL 5.0.18 Reproduce code: --------------- Database connection is successful, and mode is set to throw exceptions: try { $sth = $dbh->prepare("SELECT * from any_table where 1=2"); $sth->execute(); $row = $sth->fetch(); echo "ERROR=" . $sth->errorCode(); } catch (PDOException $e) { dbg("DB Error!: " . $e->getMessage()); die(); } Expected result: ---------------- Either ERROR=20 when not using exceptions, or an exception. Actual result: -------------- ERROR=00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36578&edit=1

« previous php.bugs (#93814) next »