xref: /PHP-8.2/ext/pdo_mysql/tests/bug78152.phpt (revision b5a14e6c)
1--TEST--
2Bug #78152: PDO::exec() - Bad error handling with multiple commands
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12
13require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14$db = MySQLPDOTest::factory();
15MySQLPDOTest::createTestTable($db);
16
17var_dump($db->exec("INSERT INTO test(id, label) VALUES (41, 'x'); INSERT INTO test_bad(id, label) VALUES (42, 'y')"));
18$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
19try {
20    var_dump($db->exec("INSERT INTO test(id, label) VALUES (42, 'x'); INSERT INTO test_bad(id, label) VALUES (43, 'y')"));
21} catch (PDOException $e) {
22    echo $e->getMessage(), "\n";
23}
24
25?>
26--CLEAN--
27<?php
28require dirname(__FILE__) . '/mysql_pdo_test.inc';
29MySQLPDOTest::dropTestTable();
30?>
31--EXPECTF--
32Warning: PDO::exec(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test_bad' doesn't exist in %s on line %d
33bool(false)
34SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test_bad' doesn't exist
35