summaryrefslogtreecommitdiff
path: root/ext/oci8/tests/fetch.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/oci8/tests/fetch.phpt')
-rw-r--r--ext/oci8/tests/fetch.phpt70
1 files changed, 45 insertions, 25 deletions
diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt
index 33cba657b..520632494 100644
--- a/ext/oci8/tests/fetch.phpt
+++ b/ext/oci8/tests/fetch.phpt
@@ -5,28 +5,39 @@ ocifetch() & ociresult()
--FILE--
<?php
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+// Initialize
-if (!($s = oci_parse($c, $insert_sql))) {
- die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+ "drop table fetch_tab",
+ "create table fetch_tab (id number, value number)",
+ "insert into fetch_tab (id, value) values (1,1)",
+ "insert into fetch_tab (id, value) values (1,1)",
+ "insert into fetch_tab (id, value) values (1,1)",
+);
-for ($i = 0; $i<3; $i++) {
- if (!oci_execute($s)) {
- die("oci_execute(insert) failed!\n");
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $m = oci_error($s);
+ if (!in_array($m['code'], array( // ignore expected errors
+ 942 // table or view does not exist
+ ))) {
+ echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ }
}
}
-if (!oci_commit($c)) {
- die("oci_commit() failed!\n");
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
}
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+// Run Test
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from fetch_tab"))) {
die("oci_parse(select) failed!\n");
}
@@ -35,22 +46,31 @@ if (!oci_execute($s)) {
}
while(ocifetch($s)) {
- $i = 1;
- while ($row = ociresult($s, $i)) {
- $i++;
+ $row = ociresult($s, 1);
+ $row1 = ociresult($s, 2);
var_dump($row);
- }
+ var_dump($row1);
+}
+
+// Cleanup
+
+$stmtarray = array(
+ "drop table fetch_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
}
-require dirname(__FILE__).'/drop_table.inc';
echo "Done\n";
?>
---EXPECT--
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
+--EXPECTF--
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
Done