Edit report at http://bugs.php.net/bug.php?id=53782&edit=1
ID: 53782 Updated by: u...@php.net Reported by: david at grudl dot com Summary: foreach throws irrelevant exception -Status: Open +Status: Bogus Type: Bug Package: PDO related Operating System: Windows 7 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Running errenous query and not expecting exception is bogus. Previous Comments: ------------------------------------------------------------------------ [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