bug78152.phpt 1.1 KB

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