--TEST-- PDO Common: PDOStatement SPL iterator --EXTENSIONS-- pdo --SKIPIF-- --FILE-- exec('CREATE TABLE test031(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); $stmt = $db->prepare("INSERT INTO test031 VALUES(?, ?, ?)"); foreach ($data as $row) { $stmt->execute($row); } unset($stmt); echo "===QUERY===\n"; $stmt = $db->query('SELECT * FROM test031'); foreach(new RecursiveTreeIterator(new RecursiveArrayIterator($stmt->fetchAll(PDO::FETCH_ASSOC)), RecursiveTreeIterator::BYPASS_KEY) as $c=>$v) { echo "$v [$c]\n"; } echo "===DONE===\n"; exit(0); ?> --CLEAN-- --EXPECT-- ===QUERY=== |-Array [0] | |-10 [id] | |-Abc [val] | \-zxy [val2] |-Array [1] | |-20 [id] | |-Def [val] | \-wvu [val2] \-Array [2] |-30 [id] |-Ghi [val] \-tsr [val2] ===DONE===