xref: /PHP-8.4/ext/pdo/tests/bug_38253.phpt (revision f4a5db3e)
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 test38253 (id integer primary key, n varchar(255))");
19$pdo->exec ("INSERT INTO test38253 (id, n) VALUES (1, 'hi')");
20
21$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS);
22$stmt = $pdo->prepare ("SELECT * FROM test38253");
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 test38253");
28$stmt->execute();
29var_dump($stmt->fetchAll());
30
31?>
32--CLEAN--
33<?php
34require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
35$db = PDOTest::factory();
36PDOTest::dropTableIfExists($db, "test38253");
37?>
38--EXPECTF--
39Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch class specified in %s on line %d
40
41Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
42array(0) {
43}
44
45Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch function specified in %s on line %d
46
47Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
48array(0) {
49}
50