xref: /PHP-7.4/ext/pdo/tests/bug_42917.phpt (revision 26dfce7f)
1--TEST--
2PDO Common: Bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode)
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->exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))");
18
19for ($i = 0; $i < 5; $i++) {
20	$db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')");
21}
22
23$res = $db->query("SELECT a,b FROM test");
24$res->setFetchMode(PDO::FETCH_KEY_PAIR);
25var_dump($res->fetchAll());
26
27?>
28--EXPECT--
29array(5) {
30  ["test0"]=>
31  string(1) "0"
32  ["test1"]=>
33  string(1) "1"
34  ["test2"]=>
35  string(1) "2"
36  ["test3"]=>
37  string(1) "3"
38  ["test4"]=>
39  string(1) "4"
40}
41