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 test (a varchar(100), b varchar(100), c varchar(100))"); 19 20for ($i = 0; $i < 5; $i++) { 21 $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); 22} 23 24$res = $db->query("SELECT a,b FROM test"); 25$res->setFetchMode(PDO::FETCH_KEY_PAIR); 26var_dump($res->fetchAll()); 27 28?> 29--EXPECT-- 30array(5) { 31 ["test0"]=> 32 string(1) "0" 33 ["test1"]=> 34 string(1) "1" 35 ["test2"]=> 36 string(1) "2" 37 ["test3"]=> 38 string(1) "3" 39 ["test4"]=> 40 string(1) "4" 41} 42