--TEST-- PDO MySQL Bug #53782 (foreach throws irrelevant exception) --EXTENSIONS-- pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $res = $conn->query('SELECT 0'); try { $conn->query('ERROR'); } catch (PDOException $e) { echo "Caught: ".$e->getMessage()."\n"; } foreach ($res as $k => $v) { echo "Value: $v[0]\n"; } echo "DONE"; ?> --CLEAN-- --EXPECTF-- Caught: SQLSTATE[42000]: %s Value: 0 DONE