Bug #53782 [Opn->Bgs]: foreach throws irrelevant exception

From: Date: Tue, 10 May 2011 08:06:47 +0000
Subject: Bug #53782 [Opn->Bgs]: foreach throws irrelevant exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160638@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53782&edit=1 ID: 53782 Updated by: uw@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

« previous php.bugs (#160638) next »