1--TEST-- 2PDO Common: PDO::FETCH_ASSOC 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, 'B')"); 20$db->exec("INSERT INTO test VALUES(3, 'C')"); 21 22$stmt = $db->prepare('SELECT * from test'); 23$stmt->execute(); 24 25var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 26?> 27--EXPECT-- 28array(3) { 29 [0]=> 30 array(2) { 31 ["id"]=> 32 string(1) "1" 33 ["val"]=> 34 string(1) "A" 35 } 36 [1]=> 37 array(2) { 38 ["id"]=> 39 string(1) "2" 40 ["val"]=> 41 string(1) "B" 42 } 43 [2]=> 44 array(2) { 45 ["id"]=> 46 string(1) "3" 47 ["val"]=> 48 string(1) "C" 49 } 50} 51