1--TEST-- 2PDO MySQL Bug #53782 (foreach throws irrelevant exception) 3--EXTENSIONS-- 4pdo 5pdo_mysql 6--SKIPIF-- 7<?php 8require __DIR__ . '/config.inc'; 9require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 10PDOTest::skip(); 11?> 12--FILE-- 13<?php 14require __DIR__ . '/config.inc'; 15require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 16$conn = PDOTest::test_factory(__DIR__ . '/common.phpt'); 17 18$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 19 20$res = $conn->query('SELECT 0'); 21 22try { 23 $conn->query('ERROR'); 24} catch (PDOException $e) { 25 echo "Caught: ".$e->getMessage()."\n"; 26} 27 28foreach ($res as $k => $v) { 29 echo "Value: $v[0]\n"; 30} 31 32echo "DONE"; 33?> 34--CLEAN-- 35<?php 36require __DIR__ . '/mysql_pdo_test.inc'; 37MySQLPDOTest::dropTestTable(); 38?> 39--EXPECTF-- 40Caught: SQLSTATE[42000]: %s 41Value: 0 42DONE 43