xref: /PHP-8.1/ext/pdo/tests/bug_79106.phpt (revision 74859783)
1--TEST--
2Bug #79106 (PDO may fetch wrong column indexes with PDO::FETCH_BOTH)
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (!$dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10try {
11    $db = PDOTest::factory();
12} catch (PDOException $e) {
13    die('skip ' . $e->getMessage());
14}
15if (@$db->query('SELECT 1 as "1"') === false) {
16    die('skip driver does not support quoted numeric identifiers');
17}
18?>
19--FILE--
20<?php
21if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR=' . dirname(__FILE__) . '/../../pdo/tests/');
22require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
23$db = PDOTest::factory();
24
25$stmt = $db->query('SELECT 0 as "2007", 0 as "2008", 0 as "2020"');
26var_dump($stmt->fetchAll());
27?>
28--EXPECT--
29array(1) {
30  [0]=>
31  array(6) {
32    [2007]=>
33    string(1) "0"
34    [0]=>
35    string(1) "0"
36    [2008]=>
37    string(1) "0"
38    [1]=>
39    string(1) "0"
40    [2020]=>
41    string(1) "0"
42    [2]=>
43    string(1) "0"
44  }
45}
46