xref: /PHP-8.0/ext/pdo/tests/bug_43139.phpt (revision f8d79582)
1--TEST--
2PDO Common: Bug #43139 (PDO ignore ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll())
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8require_once $dir . 'pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15$db = PDOTest::factory();
16
17$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
18$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
19
20$from = '';
21if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
22    $from = 'from dual';
23} else if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'firebird') {
24    $from = 'FROM RDB$DATABASE';
25}
26
27var_dump($db->query("select 0 as abc, 1 as xyz, 2 as def $from")->fetchAll(PDO::FETCH_GROUP));
28?>
29--EXPECT--
30array(1) {
31  [0]=>
32  array(1) {
33    [0]=>
34    array(2) {
35      ["xyz"]=>
36      string(1) "1"
37      ["def"]=>
38      string(1) "2"
39    }
40  }
41}
42