Add test for PDOStatement::getColumnMeta().

Note that PDO_ODBC test fails as it is currently unimplemented.
This commit is contained in:
Dan Scott 2005-03-09 00:20:07 +00:00
parent ddde4497b2
commit e90582a990
2 changed files with 125 additions and 0 deletions

41
ext/pdo/tests/pdo_022.inc Executable file
View File

@ -0,0 +1,41 @@
<?php # vim:ft=php
require_once('pdo.inc');
set_sql('create1', 'CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))');
set_sql('insert1', "INSERT INTO test VALUES(?, ?, ?)");
set_sql('insert2', "INSERT INTO test VALUES(:first, :second, :third)");
set_sql('select1', 'SELECT id, val, val2 FROM test');
set_sql('select2', 'SELECT COUNT(*) FROM test');
$data = array(
array('10', 'Abc', 'zxy'),
array('20', 'Def', 'wvu'),
array('30', 'Ghi', 'tsr'),
array('40', 'Jkl', 'qpo'),
array('50', 'Mno', 'nml'),
array('60', 'Pqr', 'kji'),
);
$DB->exec($SQL['create1']);
// Insert using question mark placeholders
$stmt = $DB->prepare($SQL['insert1']);
foreach ($data as $row) {
$stmt->execute($row);
}
// Retrieve column metadata for a result set returned by explicit SELECT
$select = $DB->query($SQL['select1']);
$meta = $select->getColumnMeta(0);
var_dump($meta);
$meta = $select->getColumnMeta(1);
var_dump($meta);
$meta = $select->getColumnMeta(2);
var_dump($meta);
// Retrieve column metadata for a result set returned by a function
$select = $DB->query($SQL['select2']);
$meta = $select->getColumnMeta(0);
var_dump($meta);
?>

84
ext/pdo_odbc/tests/pdo_022.phpt Executable file
View File

@ -0,0 +1,84 @@
--TEST--
PDO_ODBC: PDOStatement::columnMeta results.
--SKIPIF--
<?php # vim:ft=php
require_once('skipif.inc'); ?>
--FILE--
<?php
require_once('connection.inc');
require_once('prepare.inc');
require_once($PDO_TESTS . 'pdo_022.inc');
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
array(7) {
["native_type"]=>
string(7) "integer"
["odbc:decl_type"]=>
string(3) "INT"
["flags"]=>
array(0) {
}
["name"]=>
string(2) "id"
["len"]=>
int(-1)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
array(7) {
["native_type"]=>
string(6) "string"
["odbc:decl_type"]=>
string(11) "VARCHAR(10)"
["flags"]=>
array(0) {
}
["name"]=>
string(3) "val"
["len"]=>
int(-1)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
array(7) {
["native_type"]=>
string(6) "string"
["odbc:decl_type"]=>
string(11) "VARCHAR(16)"
["flags"]=>
array(0) {
}
["name"]=>
string(4) "val2"
["len"]=>
int(-1)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
array(6) {
["native_type"]=>
string(7) "integer"
["flags"]=>
array(0) {
}
["name"]=>
string(8) "COUNT(*)"
["len"]=>
int(-1)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
===DONE===