1--TEST-- 2PDO Common: PDO::FETCH_COLUMN 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 test015(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(20))'); 19$db->exec("INSERT INTO test015 VALUES(1, 'A', 'A2')"); 20$db->exec("INSERT INTO test015 VALUES(2, 'A', 'B2')"); 21 22$select1 = $db->prepare('SELECT id, val, val2 FROM test015'); 23$select2 = $db->prepare('SELECT val, val2 FROM test015'); 24 25$select1->execute(); 26var_dump($select1->fetchAll(PDO::FETCH_COLUMN)); 27$select1->execute(); 28var_dump($select1->fetchAll(PDO::FETCH_COLUMN, 2)); 29$select1->execute(); 30var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); 31$select1->execute(); 32var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); 33$select1->execute(); 34var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 0)); 35$select1->execute(); 36var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 1)); 37$select1->execute(); 38var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 2)); 39 40$select2->execute(); 41var_dump($select2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); 42 43?> 44--CLEAN-- 45<?php 46require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 47$db = PDOTest::factory(); 48PDOTest::dropTableIfExists($db, "test015"); 49?> 50--EXPECT-- 51array(2) { 52 [0]=> 53 string(1) "1" 54 [1]=> 55 string(1) "2" 56} 57array(2) { 58 [0]=> 59 string(2) "A2" 60 [1]=> 61 string(2) "B2" 62} 63array(2) { 64 [1]=> 65 array(1) { 66 [0]=> 67 string(1) "A" 68 } 69 [2]=> 70 array(1) { 71 [0]=> 72 string(1) "A" 73 } 74} 75array(2) { 76 [1]=> 77 string(1) "A" 78 [2]=> 79 string(1) "A" 80} 81array(2) { 82 [1]=> 83 string(1) "1" 84 [2]=> 85 string(1) "2" 86} 87array(2) { 88 [1]=> 89 string(1) "A" 90 [2]=> 91 string(1) "A" 92} 93array(2) { 94 [1]=> 95 string(2) "A2" 96 [2]=> 97 string(2) "B2" 98} 99array(1) { 100 ["A"]=> 101 array(2) { 102 [0]=> 103 string(2) "A2" 104 [1]=> 105 string(2) "B2" 106 } 107} 108