xref: /PHP-8.2/ext/pdo/tests/bug_43139.phpt (revision 74859783)
1--TEST--
2PDO Common: Bug #43139 (PDO ignore ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll())
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$db = PDOTest::factory();
17
18$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
19$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
20
21$from = '';
22if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
23    $from = 'from dual';
24} else if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'firebird') {
25    $from = 'FROM RDB$DATABASE';
26}
27
28var_dump($db->query("select 0 as abc, 1 as xyz, 2 as def $from")->fetchAll(PDO::FETCH_GROUP));
29?>
30--EXPECT--
31array(1) {
32  [0]=>
33  array(1) {
34    [0]=>
35    array(2) {
36      ["xyz"]=>
37      string(1) "1"
38      ["def"]=>
39      string(1) "2"
40    }
41  }
42}
43