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