Bug #53782 [Bgs->ReO]: foreach throws irrelevant exception
| From: | vrana@php.net | Date: | Thu, 12 May 2011 14:31:10 +0000 |
| Subject: | Bug #53782 [Bgs->ReO]: foreach throws irrelevant exception | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160695@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: vrana@php.net
Reported by: david at grudl dot com
Summary: foreach throws irrelevant exception
-Status: Bogus
+Status: Re-Opened
Type: Bug
Package: PDO related
Operating System: Windows 7
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This seems like a real bug, example is correct.
Previous Comments:
------------------------------------------------------------------------
[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] uw@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