1--TEST-- 2PDO Common: PDOStatement SPL iterator 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 17$data = array( 18 array('10', 'Abc', 'zxy'), 19 array('20', 'Def', 'wvu'), 20 array('30', 'Ghi', 'tsr'), 21); 22 23$db = PDOTest::factory(); 24 25$db->exec('CREATE TABLE test031(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); 26 27$stmt = $db->prepare("INSERT INTO test031 VALUES(?, ?, ?)"); 28foreach ($data as $row) { 29 $stmt->execute($row); 30} 31 32unset($stmt); 33 34echo "===QUERY===\n"; 35 36$stmt = $db->query('SELECT * FROM test031'); 37 38foreach(new RecursiveTreeIterator(new RecursiveArrayIterator($stmt->fetchAll(PDO::FETCH_ASSOC)), RecursiveTreeIterator::BYPASS_KEY) as $c=>$v) 39{ 40 echo "$v [$c]\n"; 41} 42 43echo "===DONE===\n"; 44exit(0); 45?> 46--CLEAN-- 47<?php 48require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 49$db = PDOTest::factory(); 50PDOTest::dropTableIfExists($db, "test031"); 51?> 52--EXPECT-- 53===QUERY=== 54|-Array [0] 55| |-10 [id] 56| |-Abc [val] 57| \-zxy [val2] 58|-Array [1] 59| |-20 [id] 60| |-Def [val] 61| \-wvu [val2] 62\-Array [2] 63 |-30 [id] 64 |-Ghi [val] 65 \-tsr [val2] 66===DONE=== 67