bug66033.phpt 732 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Bug #66033 (Segmentation Fault when constructor of PDO statement throws an exception)
  3. --EXTENSIONS--
  4. pdo_sqlite
  5. --FILE--
  6. <?php
  7. class DBStatement extends PDOStatement {
  8. public $dbh;
  9. protected function __construct($dbh) {
  10. $this->dbh = $dbh;
  11. throw new Exception("Blah");
  12. }
  13. }
  14. $pdo = new PDO('sqlite::memory:', null, null);
  15. $pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement',
  16. array($pdo)));
  17. $pdo->exec("CREATE TABLE IF NOT EXISTS messages (
  18. id INTEGER PRIMARY KEY,
  19. title TEXT,
  20. message TEXT,
  21. time INTEGER)");
  22. try {
  23. $pdoStatement = $pdo->query("select * from messages");
  24. } catch (Exception $e) {
  25. var_dump($e->getMessage());
  26. }
  27. ?>
  28. --EXPECT--
  29. string(4) "Blah"