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