1--TEST-- 2PDO Common: PDO::FETCH_GROUP 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(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); 18$db->exec("INSERT INTO test VALUES(1, 'A')"); 19$db->exec("INSERT INTO test VALUES(2, 'A')"); 20$db->exec("INSERT INTO test VALUES(3, 'C')"); 21 22$stmt = $db->prepare('SELECT val, id from test'); 23 24$stmt->execute(); 25var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_GROUP)); 26 27$stmt->execute(); 28var_dump($stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_GROUP)); 29 30?> 31--EXPECT-- 32array(2) { 33 ["A"]=> 34 array(2) { 35 [0]=> 36 array(1) { 37 [0]=> 38 string(1) "1" 39 } 40 [1]=> 41 array(1) { 42 [0]=> 43 string(1) "2" 44 } 45 } 46 ["C"]=> 47 array(1) { 48 [0]=> 49 array(1) { 50 [0]=> 51 string(1) "3" 52 } 53 } 54} 55array(2) { 56 ["A"]=> 57 array(2) { 58 [0]=> 59 array(1) { 60 ["id"]=> 61 string(1) "1" 62 } 63 [1]=> 64 array(1) { 65 ["id"]=> 66 string(1) "2" 67 } 68 } 69 ["C"]=> 70 array(1) { 71 [0]=> 72 array(1) { 73 ["id"]=> 74 string(1) "3" 75 } 76 } 77} 78