]> granicus.if.org Git - php/commitdiff
refactor tests
authorChristopher Jones <sixd@php.net>
Fri, 2 Oct 2009 20:16:59 +0000 (20:16 +0000)
committerChristopher Jones <sixd@php.net>
Fri, 2 Oct 2009 20:16:59 +0000 (20:16 +0000)
22 files changed:
ext/oci8/tests/bug26133.phpt
ext/oci8/tests/bug32325.phpt
ext/oci8/tests/cursor_bind_err.phpt
ext/oci8/tests/cursors_old.phpt
ext/oci8/tests/default_prefetch.phpt
ext/oci8/tests/default_prefetch1.phpt
ext/oci8/tests/default_prefetch2.phpt
ext/oci8/tests/define.phpt
ext/oci8/tests/define1.phpt
ext/oci8/tests/define4.phpt
ext/oci8/tests/define5.phpt
ext/oci8/tests/define_old.phpt
ext/oci8/tests/fetch.phpt
ext/oci8/tests/fetch_all.phpt
ext/oci8/tests/fetch_all3.phpt
ext/oci8/tests/fetch_into.phpt
ext/oci8/tests/fetch_row.phpt
ext/oci8/tests/field_funcs1.phpt
ext/oci8/tests/field_funcs2.phpt
ext/oci8/tests/num.phpt
ext/oci8/tests/prefetch.phpt
ext/oci8/tests/prefetch_old.phpt

index df319feb05eba05bfa97304bb6203233cc086271..2463e70c767aacc4646a3ee5cf37c66d19c6b86e 100644 (file)
@@ -5,30 +5,58 @@ Bug #26133 (ocifreedesc() segfault)
 --FILE--
 <?php
 
-    require dirname(__FILE__).'/connect.inc';
-    require dirname(__FILE__).'/create_table.inc';
-
-    if ($c) {
-        $ora_sql = "INSERT INTO 
-                               ".$schema.$table_name." (id, value) 
-                         VALUES ('1','1')
-                      RETURNING 
-                               ROWID 
-                           INTO :v_rowid ";
-                      
-        $statement = OCIParse($c,$ora_sql);
-        $rowid = OCINewDescriptor($c,OCI_D_ROWID);
-        OCIBindByName($statement,":v_rowid", $rowid,-1,OCI_B_ROWID);
-        if (OCIExecute($statement)) {
-            OCICommit($c);
-        }
-        OCIFreeStatement($statement);
-        $rowid->free();
-    }
-
-    require dirname(__FILE__).'/drop_table.inc';
-    
-    echo "Done\n";
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialize
+
+$stmtarray = array(
+    "drop table bug26133_tab",
+    "create table bug26133_tab (id number, value number)",
+);
+
+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;
+               }
+       }
+}
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+
+// Run Test
+
+$ora_sql = "INSERT INTO bug26133_tab (id, value) VALUES ('1','1') RETURNING ROWID INTO :v_rowid ";
+
+$statement = OCIParse($c,$ora_sql);
+$rowid = OCINewDescriptor($c,OCI_D_ROWID);
+OCIBindByName($statement,":v_rowid", $rowid,-1,OCI_B_ROWID);
+if (OCIExecute($statement)) {
+    OCICommit($c);
+}
+OCIFreeStatement($statement);
+$rowid->free();
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table bug26133_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+                         
+echo "Done\n";
 ?>
 --EXPECT--
 Done
index 00054f51e173dbf2b7ad144a3afa649034b25052..257c6977b8e63af597411f7b509f639e2227e1b1 100644 (file)
@@ -1,21 +1,37 @@
 --TEST--
-Bug #32325 (Can't retrieve collection using OCI8)
+Bug #32325 (Cannot retrieve collection using OCI8)
 --SKIPIF--
 <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
 --FILE--
 <?php
 
-require dirname(__FILE__).'/connect.inc';
-require dirname(__FILE__).'/create_table.inc';
-                       
-$create_stmt = oci_parse($c, "create or replace type ut_num_list_t as table of number");
-oci_execute($create_stmt);
-
-$collection = oci_new_collection($c, "UT_NUM_LIST_T");
-
-$sql  = "
-        begin
-               select ut_num_list_t(1,2,3,4) into :list from dual;
+require(dirname(__FILE__).'/connect.inc');
+               
+// Initialize
+
+$stmtarray = array(
+    "create or replace type bug32325_t as table of number"
+);
+
+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;
+               }
+       }
+}
+
+// Run test
+       
+$collection = oci_new_collection($c, "BUG32325_T");
+
+$sql = "begin
+               select bug32325_t(1,2,3,4) into :list from dual;
                end;";
 
 $stmt = oci_parse($c, $sql);
@@ -27,12 +43,20 @@ var_dump($collection->size());
 var_dump($collection->getelem(1));
 var_dump($collection->getelem(2));
 
-$drop_stmt = oci_parse($c, "drop type ut_num_list_t");
-oci_execute($drop_stmt);
+// Cleanup
+
+$stmtarray = array(
+    "drop type bug32325_t"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 ?>
---EXPECTF--    
+--EXPECT--     
 int(4)
 float(2)
 float(3)
index 267c4d94fb556352e2476498232bcdcffa1a5efe..33bd04b6d22dbb484121f727b318af25a65b0abf 100644 (file)
@@ -5,26 +5,39 @@ binding a cursor (with errors)
 --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 cursor_bind_err_tab",
+    "create table cursor_bind_err_tab (id number, value number)",
+    "insert into cursor_bind_err_tab (id, value) values (1,1)",
+    "insert into cursor_bind_err_tab (id, value) values (1,1)",
+    "insert into cursor_bind_err_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);
 }
 
-$sql = "select CURSOR(select * from ".$schema.$table_name.") into :cursor from dual";
+// Run Test
+
+$sql = "select cursor(select * from cursor_bind_err_tab) into :cursor from dual";
 $stmt = oci_parse($c, $sql);
 
 $cursor = oci_new_cursor($c);
@@ -35,14 +48,23 @@ oci_execute($stmt);
 oci_execute($cursor);
 var_dump(oci_fetch_assoc($cursor));
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table cursor_bind_err_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
 --EXPECTF--
-Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number in %s on line %d
+Warning: oci_bind_by_name(): ORA-01036: %s in %s on line %d
 
-Warning: oci_fetch_assoc(): ORA-24338: statement handle not executed in %s on line %d
+Warning: oci_fetch_assoc(): ORA-24338: %s in %s on line %d
 bool(false)
 Done
index cf3b5f957570f48959c5f3750a103393daf00f3e..73447c82b4ffc28e73c48588f2fcaf37299fa594 100644 (file)
@@ -5,26 +5,39 @@ fetching cursor from a statement
 --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 = ociparse($c, $insert_sql))) {
-       die("ociparse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table cursors_old_tab",
+    "create table cursors_old_tab (id number, value number)",
+    "insert into cursors_old_tab (id, value) values (1,1)",
+    "insert into cursors_old_tab (id, value) values (1,1)",
+    "insert into cursors_old_tab (id, value) values (1,1)",
+);
 
-for ($i = 0; $i<3; $i++) {
-       if (!ociexecute($s)) {
-               die("ociexecute(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 (!ocicommit($c)) {
-       die("ocicommit() failed!\n");
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
 }
 
-$sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual";
+// Run Test
+
+$sql = "select cursor(select * from cursors_old_tab) as curs from dual";
 $stmt = ociparse($c, $sql);
 
 ociexecute($stmt);
@@ -39,26 +52,35 @@ while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) {
        var_dump(ocicancel($data["CURS"]));
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table cursors_old_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
 --EXPECTF--
 array(2) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
+  [%u|b%"ID"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"VALUE"]=>
+  %unicode|string%(1) "1"
 }
 bool(true)
 
-Warning: ocifetchinto():%sORA-01002: fetch out of sequence in %scursors_old.php on line %d
+Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d
 array(2) {
-  ["ID"]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
+  [%u|b%"ID"]=>
+  %unicode|string%(1) "1"
+  [%u|b%"VALUE"]=>
+  %unicode|string%(1) "1"
 }
 bool(true)
 Done
index cc02b6a1c39b5a8c4e76e04507aafcf98780fd56..47191c8585b518d1a919353b18fd576ee249e7aa 100644 (file)
@@ -7,26 +7,39 @@ oci8.default_prefetch=20
 --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 default_prefetch_tab",
+    "create table default_prefetch_tab (id number, value number)",
+    "insert into default_prefetch_tab (id, value) values (1,1)",
+    "insert into default_prefetch_tab (id, value) values (1,1)",
+    "insert into default_prefetch_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
+
+$select_sql = "select * from default_prefetch_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
        die("oci_parse(select) failed!\n");
@@ -40,7 +53,17 @@ var_dump(oci_fetch($s));
 
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table default_prefetch_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+       
        
 echo "Done\n";
 ?>
index aa130e9f93ecdd607bbad03e6c2878147773f261..bcd66fa38196fbcd7e2b6b7f027f9969ae5e060d 100644 (file)
@@ -7,26 +7,39 @@ oci8.default_prefetch=100
 --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 default_prefetch1_tab",
+    "create table default_prefetch1_tab (id number, value number)",
+    "insert into default_prefetch1_tab (id, value) values (1,1)",
+    "insert into default_prefetch1_tab (id, value) values (1,1)",
+    "insert into default_prefetch1_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
+
+$select_sql = "select * from default_prefetch1_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
        die("oci_parse(select) failed!\n");
@@ -37,10 +50,19 @@ if (!oci_execute($s)) {
 }
 
 var_dump(oci_fetch($s));
-
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table default_prefetch1_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
        
 echo "Done\n";
 ?>
index ac623a2744b2b9d435c65739cd1e98e324c45fdd..7b3f29f2960c3a5185bef477ddd80f88f29574f9 100644 (file)
@@ -7,26 +7,39 @@ oci8.default_prefetch=100
 --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 default_prefetch2_tab",
+    "create table default_prefetch2_tab (id number, value number)",
+    "insert into default_prefetch2_tab (id, value) values (1,1)",
+    "insert into default_prefetch2_tab (id, value) values (1,1)",
+    "insert into default_prefetch2_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
+
+$select_sql = "select * from default_prefetch2_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
        die("oci_parse(select) failed!\n");
@@ -39,10 +52,18 @@ if (!oci_execute($s)) {
 }
 
 var_dump(oci_fetch($s));
-
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table default_prefetch2_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
        
 echo "Done\n";
 ?>
index c76f360f28e480d0fd425cf86f9be19fad6998c7..d99bc7e1a6e6287c95d4969a16c47fe902cf84c8 100644 (file)
@@ -5,24 +5,36 @@ oci_define_by_name()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
-
-$insert_sql = "INSERT INTO ".$schema.$table_name." (string) VALUES ('some')";
-
-if (!($s = oci_parse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table define_tab",
+    "create table define_tab (string varchar(10))",
+    "insert into define_tab (string) values ('some')",
+);
+
+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_execute($s)) {
-        die("oci_execute(insert) failed!\n");
-}
+// Run test
 
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name."");
+$stmt = oci_parse($c, "select string from define_tab");
 
 /* the define MUST be done BEFORE ociexecute! */
 
-$strong = '';
+$string = '';
 oci_define_by_name($stmt, "STRING", $string, 20);
 
 oci_execute($stmt);
@@ -31,11 +43,20 @@ while (oci_fetch($stmt)) {
        var_dump($string);
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
---EXPECT--
-string(4) "some"
+--EXPECTF--
+%unicode|string%(%d) "some"
 Done
index f6e04cc1857421eecd3dae027ce55c6e7ac6700a..341bc9ed83426320966ad3b76826f9aa2bf1212c 100644 (file)
@@ -5,24 +5,36 @@ oci_define_by_name()
 --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." (string) VALUES ('some')";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table define1_tab",
+    "create table define1_tab (string varchar(10))",
+    "insert into define1_tab (string) values ('some')",
+);
 
-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;
+               }
+       }
 }
 
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name."");
+// Run test
+
+$stmt = oci_parse($c, "select string from define1_tab");
 
 /* the define MUST be done BEFORE ociexecute! */
 
-$strong = '';
+$string = '';
 var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
 var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
 var_dump(oci_define_by_name($stmt, "", $string, 20));
@@ -34,7 +46,16 @@ while (oci_fetch($stmt)) {
        var_dump($string);
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define1_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
@@ -48,5 +69,5 @@ bool(false)
 
 Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d
 NULL
-string(4) "some"
+%unicode|string%(4) "some"
 Done
index 6fd9f5b93fa746bc927ac662d59506cebbef2a49..8d83f73ac3cce7f547160f0428e587fab299e49e 100644 (file)
@@ -5,20 +5,32 @@ oci_define_by_name() on partial number of columns
 --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." (value, string) VALUES (1234, 'some')";
+// Initialize
 
-if (!($s = oci_parse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
-}
+$stmtarray = array(
+    "drop table define4_tab",
+    "create table define4_tab (value number, string varchar(10))",
+    "insert into define4_tab (value, string) values (1234, 'some')",
+);
 
-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;
+               }
+       }
 }
 
-$stmt = oci_parse($c, "SELECT value, string FROM ".$table_name."");
+// Run test
+
+$stmt = oci_parse($c, "select value, string from define4_tab");
 
 echo "Test 1\n";
 // Only one of the two columns is defined
@@ -42,7 +54,16 @@ var_dump(oci_free_statement($stmt));
 var_dump($string);
 var_dump(oci_result($stmt, 'STRING'));
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define4_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
@@ -51,15 +72,15 @@ echo "Done\n";
 Test 1
 bool(true)
 Test 2
-string(4) "1234"
-string(4) "some"
-string(4) "some"
-string(4) "some"
-string(4) "1234"
-string(4) "some"
+%unicode|string%(4) "1234"
+%unicode|string%(4) "some"
+%unicode|string%(4) "some"
+%unicode|string%(4) "some"
+%unicode|string%(4) "1234"
+%unicode|string%(4) "some"
 Test 3
 bool(true)
-string(4) "some"
+%unicode|string%(4) "some"
 
 Warning: oci_result(): %d is not a valid oci8 statement resource in %s on line %d
 bool(false)
index c439b1d6484aee6876e985380d59af7042b89bac..63541ce9dd4efd22767bfbbf51c3b80fff83e0ec 100644 (file)
@@ -5,19 +5,34 @@ oci_define_by_name() for statement re-execution
 --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, string) VALUES (1, 'some')";
-$s = oci_parse($c, $insert_sql);
-var_dump(oci_execute($s));
+// Initialize
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, string) VALUES (2, 'thing')";
-$s = oci_parse($c, $insert_sql);
-var_dump(oci_execute($s));
+$stmtarray = array(
+    "drop table define5_tab",
+    "create table define5_tab (id number, string varchar(10))",
+    "insert into define5_tab (id, string) values (1, 'some')",
+    "insert into define5_tab (id, string) values (2, 'thing')",
+);
+
+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;
+               }
+       }
+}
+
+// Run test
 
 echo "Test 1 - must do define before execute\n";
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 1");
+$stmt = oci_parse($c, "select string from define5_tab where id = 1");
 oci_execute($stmt);
 var_dump(oci_define_by_name($stmt, "STRING", $string));
 while (oci_fetch($stmt)) {
@@ -26,7 +41,7 @@ while (oci_fetch($stmt)) {
 }
 
 echo "Test 2 - normal define order\n";
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 1");
+$stmt = oci_parse($c, "select string from define5_tab where id = 1");
 var_dump(oci_define_by_name($stmt, "STRING", $string));
 oci_execute($stmt);
 
@@ -35,30 +50,37 @@ while (oci_fetch($stmt)) {
 }
 
 echo "Test 3 - no new define done\n";
-$stmt = oci_parse($c, "SELECT string FROM ".$table_name." where id = 2");
+$stmt = oci_parse($c, "select string from define5_tab where id = 2");
 oci_execute($stmt);
 while (oci_fetch($stmt)) {
        var_dump($string); // not updated with new value
        var_dump(oci_result($stmt, 'STRING'));
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define5_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
---EXPECT--
-bool(true)
-bool(true)
+--EXPECTF--
 Test 1 - must do define before execute
 bool(true)
 NULL
-string(4) "some"
+%unicode|string%(4) "some"
 Test 2 - normal define order
 bool(true)
-string(4) "some"
+%unicode|string%(4) "some"
 Test 3 - no new define done
-string(4) "some"
-string(5) "thing"
+%unicode|string%(4) "some"
+%unicode|string%(5) "thing"
 Done
 
index da52e619ce5dbe671123336cc1f480a3892600c0..618f9d5f5713e61f45723a0c9181bd43e726e2e1 100644 (file)
@@ -5,24 +5,36 @@ ocidefinebyname()
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__)."/create_table.inc";
-
-$insert_sql = "INSERT INTO ".$schema.$table_name." (string) VALUES ('some')";
-
-if (!($s = ociparse($c, $insert_sql))) {
-        die("oci_parse(insert) failed!\n");
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table define_old_tab",
+    "create table define_old_tab (string varchar(10))",
+    "insert into define_old_tab (string) values ('some')",
+);
+
+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 (!ociexecute($s)) {
-        die("oci_execute(insert) failed!\n");
-}
+// Run test
 
-$stmt = ociparse($c, "SELECT string FROM ".$table_name."");
+$stmt = ociparse($c, "select string from define_old_tab");
 
 /* the define MUST be done BEFORE ociexecute! */
 
-$strong = '';
+$string = '';
 ocidefinebyname($stmt, "STRING", $string, 20);
 
 ociexecute($stmt);
@@ -31,11 +43,21 @@ while (ocifetch($stmt)) {
        var_dump($string);
 }
 
-require dirname(__FILE__)."/drop_table.inc";
+// Cleanup
+
+$stmtarray = array(
+    "drop table define_old_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+
 
 echo "Done\n";
 
 ?>
---EXPECT--
-string(4) "some"
+--EXPECTF--
+%unicode|string%(4) "some"
 Done
index 33cba657b6b4b26e1c7f9fef64de4458aab1fb0f..520632494084a72991096a723cc94e663688b38c 100644 (file)
@@ -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
index 5d3738b892aaf585dd5b5670674132637a1f299b..a007bac830088bbe7c944619f4d9bd7e90832a33 100644 (file)
@@ -5,28 +5,32 @@ oci_fetch_all()
 --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_all_tab",
+    "create table fetch_all_tab (id number, value number)",
+    "insert into fetch_all_tab (id, value) values (1,1)",
+    "insert into fetch_all_tab (id, value) values (1,1)",
+    "insert into fetch_all_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");
-}
-
-$select_sql = "SELECT * FROM ".$schema."".$table_name."";
-
-if (!($s = oci_parse($c, $select_sql))) {
+if (!($s = oci_parse($c, "select * from fetch_all_tab"))) {
        die("oci_parse(select) failed!\n");
 }
 
@@ -45,105 +49,60 @@ if (!oci_execute($s)) {
 var_dump(ocifetchstatement($s, $all));
 var_dump($all);
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_all_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
        
 echo "Done\n";
 ?>
---EXPECT--
+--EXPECTF--
 int(3)
-array(5) {
-  ["ID"]=>
+array(2) {
+  [%u|b%"ID"]=>
   array(3) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [2]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(3) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [2]=>
-    string(1) "1"
-  }
-  ["BLOB"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
-  }
-  ["CLOB"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
-  }
-  ["STRING"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
+    %unicode|string%(1) "1"
   }
 }
 int(3)
-array(5) {
-  ["ID"]=>
-  array(3) {
-    [0]=>
-    string(1) "1"
-    [1]=>
-    string(1) "1"
-    [2]=>
-    string(1) "1"
-  }
-  ["VALUE"]=>
-  array(3) {
-    [0]=>
-    string(1) "1"
-    [1]=>
-    string(1) "1"
-    [2]=>
-    string(1) "1"
-  }
-  ["BLOB"]=>
-  array(3) {
-    [0]=>
-    NULL
-    [1]=>
-    NULL
-    [2]=>
-    NULL
-  }
-  ["CLOB"]=>
+array(2) {
+  [%u|b%"ID"]=>
   array(3) {
     [0]=>
-    NULL
+    %unicode|string%(1) "1"
     [1]=>
-    NULL
+    %unicode|string%(1) "1"
     [2]=>
-    NULL
+    %unicode|string%(1) "1"
   }
-  ["STRING"]=>
+  [%u|b%"VALUE"]=>
   array(3) {
     [0]=>
-    NULL
+    %unicode|string%(1) "1"
     [1]=>
-    NULL
+    %unicode|string%(1) "1"
     [2]=>
-    NULL
+    %unicode|string%(1) "1"
   }
 }
 Done
index 503e5dd88e08c18a14a092909af7826b791a8110..42fe617dc9856914663a66b01132b64814444bb0 100644 (file)
@@ -5,11 +5,34 @@ oci_fetch_all() - all combinations of flags
 --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 (:idbv,:vbv)";
+// Initialize
 
+$stmtarray = array(
+    "drop table fetch_all3_tab",
+    "create table fetch_all3_tab (id number, value number)",
+);
+
+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;
+               }
+       }
+}
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+
+$insert_sql = "insert into fetch_all3_tab (id, value) values (:idbv,:vbv)";
 $s = oci_parse($c, $insert_sql);
 oci_bind_by_name($s, ":idbv", $idbv, SQLT_INT);
 oci_bind_by_name($s, ":vbv", $vbv, SQLT_INT);
@@ -22,7 +45,9 @@ for ($i = 1; $i <= 4; $i++) {
 
 oci_commit($c);
 
-$select_sql = "SELECT ID, VALUE FROM ".$schema."".$table_name." order by id";
+// Run Test
+
+$select_sql = "select id, value from fetch_all3_tab order by id";
 
 $s = oci_parse($c, $select_sql);
 
@@ -105,113 +130,123 @@ echo "OCI_NUM|OCI_ASSOC\n";
 oci_execute($s);
 var_dump(oci_fetch_all($s, $all, 0, -1, OCI_NUM|OCI_ASSOC));
 var_dump($all);
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_all3_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
     
 echo "Done\n";
 ?>
---EXPECT--
+--EXPECTF--
 None
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_ASSOC
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC
 int(4)
 array(2) {
-  ["ID"]=>
+  [%u|b%"ID"]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
-  ["VALUE"]=>
+  [%u|b%"VALUE"]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM
@@ -220,24 +255,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC
@@ -246,24 +281,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW
@@ -271,31 +306,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC
@@ -303,31 +338,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN
@@ -335,31 +370,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC
@@ -367,31 +402,31 @@ int(4)
 array(4) {
   [0]=>
   array(2) {
-    ["ID"]=>
-    string(1) "1"
-    ["VALUE"]=>
-    string(2) "-1"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "1"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
-    ["ID"]=>
-    string(1) "2"
-    ["VALUE"]=>
-    string(2) "-2"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "2"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
-    ["ID"]=>
-    string(1) "3"
-    ["VALUE"]=>
-    string(2) "-3"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "3"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
-    ["ID"]=>
-    string(1) "4"
-    ["VALUE"]=>
-    string(2) "-4"
+    [%u|b%"ID"]=>
+    %unicode|string%(1) "4"
+    [%u|b%"VALUE"]=>
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM
@@ -400,30 +435,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC
@@ -432,30 +467,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM
@@ -464,30 +499,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC
@@ -496,30 +531,30 @@ array(4) {
   [0]=>
   array(2) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
   }
   [1]=>
   array(2) {
     [0]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
   }
   [2]=>
   array(2) {
     [0]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [1]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
   }
   [3]=>
   array(2) {
     [0]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
     [1]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_NUM
@@ -528,24 +563,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 OCI_NUM|OCI_ASSOC
@@ -554,24 +589,24 @@ array(2) {
   [0]=>
   array(4) {
     [0]=>
-    string(1) "1"
+    %unicode|string%(1) "1"
     [1]=>
-    string(1) "2"
+    %unicode|string%(1) "2"
     [2]=>
-    string(1) "3"
+    %unicode|string%(1) "3"
     [3]=>
-    string(1) "4"
+    %unicode|string%(1) "4"
   }
   [1]=>
   array(4) {
     [0]=>
-    string(2) "-1"
+    %unicode|string%(2) "-1"
     [1]=>
-    string(2) "-2"
+    %unicode|string%(2) "-2"
     [2]=>
-    string(2) "-3"
+    %unicode|string%(2) "-3"
     [3]=>
-    string(2) "-4"
+    %unicode|string%(2) "-4"
   }
 }
 Done
index 379f5fc14eba1cd2da2d85997efc8794cabf92a2..17e06e1cf8c98beba33968a3a2f838f1a175e1a4 100644 (file)
@@ -5,78 +5,86 @@ ocifetchinto()
 --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_into_tab",
+    "create table fetch_into_tab (id number, value number)",
+    "insert into fetch_into_tab (id, value) values (1,1)",
+    "insert into fetch_into_tab (id, value) values (1,1)",
+    "insert into fetch_into_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_into_tab"))) {
        die("oci_parse(select) failed!\n");
 }
 
-/* oci_fetch_all */
+/* ocifetchinto */
 if (!oci_execute($s)) {
        die("oci_execute(select) failed!\n");
 }
 var_dump(ocifetchinto($s, $all));
 var_dump($all);
 
-/* oci_fetch_all */
+/* ocifetchinto */
 if (!oci_execute($s)) {
        die("oci_execute(select) failed!\n");
 }
 var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS));
 var_dump($all);
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_into_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
        
 echo "Done\n";
 ?>
---EXPECT--
-int(5)
+--EXPECTF--
+int(2)
 array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
 }
-int(5)
-array(10) {
+int(2)
+array(4) {
   [0]=>
-  string(1) "1"
-  ["ID"]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
+  [%u|b%"ID"]=>
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  ["VALUE"]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  ["BLOB"]=>
-  NULL
-  [3]=>
-  NULL
-  ["CLOB"]=>
-  NULL
-  [4]=>
-  NULL
-  ["STRING"]=>
-  NULL
+  %unicode|string%(1) "1"
+  [%u|b%"VALUE"]=>
+  %unicode|string%(1) "1"
 }
 Done
index a637ecc6f447c01760cb517bf10bcd9082b559d8..c6084d4fe2980acbbb019ec5dfa4d774fffe98a2 100644 (file)
@@ -5,28 +5,39 @@ oci_fetch_row()
 --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_row_tab",
+    "create table fetch_row_tab (id number, value number)",
+    "insert into fetch_row_tab (id, value) values (1,1)",
+    "insert into fetch_row_tab (id, value) values (1,1)",
+    "insert into fetch_row_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_row_tab"))) {
        die("oci_parse(select) failed!\n");
 }
 
@@ -37,46 +48,37 @@ while ($row = oci_fetch_row($s)) {
        var_dump($row);
 }
 
-require dirname(__FILE__).'/drop_table.inc';
+// Cleanup
+
+$stmtarray = array(
+    "drop table fetch_row_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
---EXPECT--
-array(5) {
+--EXPECTF--
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
-array(5) {
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
-array(5) {
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
 Done
index b41e743e41047c8a6297edefe9eb0144487dab74..0b4ad76b393d36ecab91f2e6272e9d4d341b7057 100644 (file)
@@ -5,28 +5,39 @@ oci_field_*() family
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
-
-$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
-
-if (!($s = oci_parse($c, $insert_sql))) {
-       die("oci_parse(insert) failed!\n");
-}
-
-for ($i = 0; $i<3; $i++) {
-       if (!oci_execute($s)) {
-               die("oci_execute(insert) failed!\n");
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table field_funcs1_tab",
+    "create table field_funcs1_tab (id number, value number)",
+    "insert into field_funcs1_tab (id, value) values (1,1)",
+    "insert into field_funcs1_tab (id, value) values (1,1)",
+    "insert into field_funcs1_tab (id, value) values (1,1)",
+);
+
+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 field_funcs1_tab"))) {
        die("oci_parse(select) failed!\n");
 }
 
@@ -71,23 +82,27 @@ var_dump(oci_field_size($s, array()));
 
 var_dump(oci_field_size($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table field_funcs1_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
 ?>
 --EXPECTF--
-array(5) {
+array(2) {
   [0]=>
-  string(1) "1"
+  %unicode|string%(1) "1"
   [1]=>
-  string(1) "1"
-  [2]=>
-  NULL
-  [3]=>
-  NULL
-  [4]=>
-  NULL
+  %unicode|string%(1) "1"
 }
 
 Warning: oci_field_is_null(): Invalid column index "-1" in %s on line %d
index 9b8d3e5a2846fc08b9822078621899b2e445f9d8..502d079139ab22946e92bea26436521816c1cbee 100644 (file)
@@ -5,10 +5,9 @@ Bug #41917 (invalid scale and precision)
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
 
-$s = oci_parse($c, 'drop table b41917t');
+$s = oci_parse($c, 'drop table field_funcs2_tab');
 @oci_execute($s);
 
 $t = array("C01" => "NUMBER",
@@ -29,7 +28,7 @@ $t = array("C01" => "NUMBER",
                   "C16" => "REAL",
                   );
 
-$stmt = "create table b41917t (\n";
+$stmt = "create table field_funcs2_tab (\n";
 foreach ($t as $colname => $type) {
        $stmt .= "$colname $type,\n";
 }
@@ -38,7 +37,7 @@ $stmt[strlen($stmt)-2] = ")";
 $s = oci_parse($c, $stmt);
 oci_execute($s);
 
-$s = oci_parse($c, "select * from b41917t");
+$s = oci_parse($c, "select * from field_funcs2_tab");
 oci_execute($s);
 
 for ($i = 1; $i <= oci_num_fields($s); $i++) {
@@ -67,4 +66,4 @@ C13 FLOAT: precision 126, scale -127
 C14 FLOAT(9): precision 9, scale -127
 C15 DOUBLE PRECISION: precision 126, scale -127
 C16 REAL: precision 63, scale -127
-Done
\ No newline at end of file
+Done
index 458e3774f5da2402c8cc1157bc8a1f5d3de22ae4..e9dc6a8ac2d476655c0020564b174f0f9888037a 100644 (file)
@@ -5,8 +5,34 @@ oci_num_*() family
 --FILE--
 <?php
 
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
+
+// Initialize
+
+$stmtarray = array(
+    "drop table num_tab",
+    "create table num_tab (id number, value number)",
+);
+
+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;
+               }
+       }
+}
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+
+// Run Test
 
 echo "Test 1\n";
 var_dump(ocirowcount());
@@ -14,13 +40,12 @@ var_dump(oci_num_rows());
 var_dump(ocinumcols());
 var_dump(oci_num_fields());
 
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
-
+echo "Test 2\n";
+$insert_sql = "insert into num_tab (id, value) values (1,1)";
 if (!($s = oci_parse($c, $insert_sql))) {
-  die("oci_parse(insert) failed!\n");
+    die("oci_parse(insert) failed!\n");
 }
 
-echo "Test 2\n";
 var_dump(ocirowcount($s));
 var_dump(oci_num_rows($s));
 var_dump(ocinumcols($s));
@@ -49,7 +74,7 @@ var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
 // All rows
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+$select_sql = "select * from num_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
   die("oci_parse(select) failed!\n");
@@ -83,7 +108,7 @@ var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
 // One row
-$select_sql = "SELECT id, value FROM ".$schema.$table_name." WHERE ROWNUM < 2";
+$select_sql = "SELECT id, value FROM num_tab WHERE ROWNUM < 2";
 
 if (!($s = oci_parse($c, $select_sql))) {
   die("oci_parse(select) failed!\n");
@@ -104,7 +129,7 @@ var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
 // No rows
-$select_sql = "SELECT id FROM ".$schema.$table_name." WHERE 1=0";
+$select_sql = "select id from num_tab where 1=0";
 
 if (!($s = oci_parse($c, $select_sql))) {
   die("oci_parse(select) failed!\n");
@@ -124,7 +149,7 @@ var_dump(oci_num_rows($s));
 var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
-$delete_sql = "DELETE FROM ".$schema.$table_name."";
+$delete_sql = "delete from num_tab";
 
 if (!($s = oci_parse($c, $delete_sql))) {
     die("oci_parse(delete) failed!\n");
@@ -149,7 +174,17 @@ var_dump(oci_num_rows($s));
 var_dump(ocinumcols($s));
 var_dump(oci_num_fields($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table num_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
 
 echo "Done\n";
 
@@ -191,13 +226,13 @@ int(0)
 Test 5b
 int(0)
 int(0)
-int(5)
-int(5)
+int(2)
+int(2)
 Test 5c
 int(3)
 int(3)
-int(5)
-int(5)
+int(2)
+int(2)
 Test 6
 int(1)
 int(1)
index fa4b8fdc60796fc67ae0b65b17add6cc6396988a..26762601df3521641c3f1729adc3941c735f1565 100644 (file)
@@ -5,26 +5,39 @@ oci_set_prefetch()
 --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 prefetch_tab",
+    "create table prefetch_tab (id number, value number)",
+    "insert into prefetch_tab (id, value) values (1,1)",
+    "insert into prefetch_tab (id, value) values (1,1)",
+    "insert into prefetch_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
+
+$select_sql = "select * from prefetch_tab";
 
 if (!($s = oci_parse($c, $select_sql))) {
        die("oci_parse(select) failed!\n");
@@ -37,11 +50,19 @@ if (!oci_execute($s)) {
 }
 
 var_dump(oci_fetch($s));
-
 var_dump(oci_num_rows($s));
 
-require dirname(__FILE__).'/drop_table.inc';
-       
+// Cleanup
+
+$stmtarray = array(
+    "drop table prefetch_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
+}
+
 echo "Done\n";
 ?>
 --EXPECT--
index cb9cb390e64906a1686605d95bbe71ede44c3842..c2ac8fe8415e9e8179c0a0284c7aa461c6a79220 100644 (file)
@@ -5,26 +5,41 @@ ocisetprefetch()
 --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)";
+$stmtarray = array(
+    "drop table prefetch_old_tab",
+    "create table prefetch_old_tab (id number, value number)",
+    "insert into prefetch_old_tab (id, value) values (1,1)",
+    "insert into prefetch_old_tab (id, value) values (1,1)",
+    "insert into prefetch_old_tab (id, value) values (1,1)",
+);
 
-if (!($s = ociparse($c, $insert_sql))) {
-       die("ociparse(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;
+        }
+    }
 }
 
-for ($i = 0; $i<3; $i++) {
-       if (!ociexecute($s)) {
-               die("ociexecute(insert) failed!\n");
-       }
+foreach ($stmtarray as $stmt) {
+       $s = oci_parse($c, $stmt);
+       oci_execute($s);
 }
 
+// Run Test
+
 if (!ocicommit($c)) {
        die("ocicommit() failed!\n");
 }
 
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+$select_sql = "select * from prefetch_old_tab";
 
 if (!($s = ociparse($c, $select_sql))) {
        die("ociparse(select) failed!\n");
@@ -37,10 +52,19 @@ if (!ociexecute($s)) {
 }
 
 var_dump(ocifetch($s));
-
 var_dump(ocirowcount($s));
 
-require dirname(__FILE__).'/drop_table.inc';
+
+// Cleanup
+
+$stmtarray = array(
+    "drop table prefetch_old_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+    $s = oci_parse($c, $stmt);
+    oci_execute($s);
+}
        
 echo "Done\n";
 ?>