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