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