bug_38253.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. PDO Common: Bug #38253 (PDO produces segfault with default fetch mode)
  3. --EXTENSIONS--
  4. pdo
  5. --SKIPIF--
  6. <?php
  7. $dir = getenv('REDIR_TEST_DIR');
  8. if (false == $dir) die('skip no driver');
  9. require_once $dir . 'pdo_test.inc';
  10. PDOTest::skip();
  11. ?>
  12. --FILE--
  13. <?php
  14. if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
  15. require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
  16. $pdo = PDOTest::factory();
  17. $pdo->exec ("create table test (id integer primary key, n varchar(255))");
  18. $pdo->exec ("INSERT INTO test (id, n) VALUES (1, 'hi')");
  19. $pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS);
  20. $stmt = $pdo->prepare ("SELECT * FROM test");
  21. $stmt->execute();
  22. var_dump($stmt->fetchAll());
  23. $pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC);
  24. $stmt = $pdo->prepare ("SELECT * FROM test");
  25. $stmt->execute();
  26. var_dump($stmt->fetchAll());
  27. ?>
  28. --EXPECTF--
  29. Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch class specified in %s on line %d
  30. Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
  31. array(0) {
  32. }
  33. Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch function specified in %s on line %d
  34. Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
  35. array(0) {
  36. }