1--TEST-- 2PDO Common: PDOStatement::getColumnMeta 3--SKIPIF-- 4<?php # vim:ft=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 * Note well: meta information is a nightmare to handle portably. 12 * it's not really PDOs job. 13 * We've not yet defined exactly what makes sense for getColumnMeta, 14 * so no tests make any sense to anyone. When they do, we can enable 15 * this test file. 16 * TODO: filter out driver dependent components from this common core 17 * test file. 18 */ 19?> 20--XFAIL-- 21This feature is not yet finalized, no test makes sense 22--FILE-- 23<?php 24if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); 25require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 26$db = PDOTest::factory(); 27 28$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); 29$db->exec('insert2', "INSERT INTO test VALUES(:first, :second, :third)"); 30 31$data = array( 32 array('10', 'Abc', 'zxy'), 33 array('20', 'Def', 'wvu'), 34 array('30', 'Ghi', 'tsr'), 35 array('40', 'Jkl', 'qpo'), 36 array('50', 'Mno', 'nml'), 37 array('60', 'Pqr', 'kji'), 38); 39 40 41// Insert using question mark placeholders 42$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)"); 43foreach ($data as $row) { 44 $stmt->execute($row); 45} 46 47// Retrieve column metadata for a result set returned by explicit SELECT 48$select = $db->query('SELECT id, val, val2 FROM test'); 49$meta = $select->getColumnMeta(0); 50var_dump($meta); 51$meta = $select->getColumnMeta(1); 52var_dump($meta); 53$meta = $select->getColumnMeta(2); 54var_dump($meta); 55 56// Retrieve column metadata for a result set returned by a function 57$select = $db->query('SELECT COUNT(*) FROM test'); 58$meta = $select->getColumnMeta(0); 59var_dump($meta); 60 61?> 62--EXPECT-- 63The unexpected! 64