Edit report at http://bugs.php.net/bug.php?id=53782&edit=1
ID: 53782 Updated by: johan...@php.net Reported by: david at grudl dot com Summary: foreach throws irrelevant exception -Status: Re-Opened +Status: Closed Type: Bug Package: PDO related Operating System: Windows 7 PHP Version: Irrelevant -Assigned To: +Assigned To: johannes Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. 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. Previous Comments: ------------------------------------------------------------------------ [2011-05-16 17:37:40] johan...@php.net Automatic comment from SVN on behalf of johannes Revision: http://svn.php.net/viewvc/?view=revision&revision=311088 Log: - Fix Bug #53782 (foreach throws irrelevant exception) ------------------------------------------------------------------------ [2011-05-12 16:31:09] vr...@php.net This seems like a real bug, example is correct. ------------------------------------------------------------------------ [2011-05-10 14:37:33] david at grudl dot com This is a serious bug in the PDO. Look at the example more closely. Variable $res has nothing to do with errenous query. ------------------------------------------------------------------------ [2011-05-10 10:06:47] u...@php.net Running errenous query and not expecting exception is bogus. ------------------------------------------------------------------------ [2011-01-18 21:30:47] david at grudl dot com Description: ------------ Iteration using foreach throws "previous" and irrelevant exception. Exception is throwed after last iteration. Test script: --------------- $conn = new PDO("mysql:dbname=test"); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $res = $conn->query('SELECT * FROM categories'); try { $conn->query('ERROR'); } catch (PDOException $e) { // exception is catched } foreach ($res as $k => $v); // now is throwed exception $e !!! Expected result: ---------------- do nothing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53782&edit=1