forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbug53782.phpt
40 lines (35 loc) · 934 Bytes
/
bug53782.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--TEST--
PDO MySQL Bug #53782 (foreach throws irrelevant exception)
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
$conn = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$conn->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--
<?php
require dirname(__FILE__) . '/mysql_pdo_test.inc';
MySQLPDOTest::dropTestTable();
?>
--EXPECTF--
Caught: SQLSTATE[42000]: %s
Value: 0
DONE