]> granicus.if.org Git - php/commitdiff
Add a test for PDOStatement::columnCount().
authorDan Scott <dbs@php.net>
Tue, 8 Mar 2005 17:39:41 +0000 (17:39 +0000)
committerDan Scott <dbs@php.net>
Tue, 8 Mar 2005 17:39:41 +0000 (17:39 +0000)
ext/pdo/tests/pdo_020.inc [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_020.phpt [new file with mode: 0755]

diff --git a/ext/pdo/tests/pdo_020.inc b/ext/pdo/tests/pdo_020.inc
new file mode 100755 (executable)
index 0000000..b04eba2
--- /dev/null
@@ -0,0 +1,28 @@
+<?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(1, 'A', 'A')"); 
+set_sql('insert2', "INSERT INTO test VALUES(2, 'B', 'B')"); 
+set_sql('insert3', "INSERT INTO test VALUES(3, 'C', 'C')");
+set_sql('select1',  'SELECT id, val FROM test');
+set_sql('select2',  'SELECT id, val, val2 FROM test');
+set_sql('select3',  'SELECT COUNT(*) FROM test');
+
+function countColumns($DB, $action) {
+    global $SQL;
+    $stmt = $DB->query($SQL[$action]);
+    $res = $stmt->columnCount();
+    return "Counted $res columns after $action.\n";
+}
+
+$DB->exec($SQL['create1']);
+$DB->exec($SQL['insert1']); 
+$DB->exec($SQL['insert2']); 
+$DB->exec($SQL['insert3']); 
+
+echo countColumns($DB, 'select1');
+echo countColumns($DB, 'select2');
+echo countColumns($DB, 'select3');
+?>
diff --git a/ext/pdo_odbc/tests/pdo_020.phpt b/ext/pdo_odbc/tests/pdo_020.phpt
new file mode 100755 (executable)
index 0000000..8e00dbd
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+PDO_ODBC: PDOStatement::columnCount
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_020.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+Counted 2 columns after select1.
+Counted 3 columns after select2.
+Counted 1 columns after select3.
+===DONE===