diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:13 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:13 -0400 |
| commit | 0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch) | |
| tree | d5107db4b7369603ac7c753829e8972ee74949f7 /ext/oci8/tests | |
| parent | ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff) | |
| download | php-upstream/5.1.2.tar.gz | |
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'ext/oci8/tests')
138 files changed, 7749 insertions, 33 deletions
diff --git a/ext/oci8/tests/array_bind_001.phpt b/ext/oci8/tests/array_bind_001.phpt new file mode 100644 index 000000000..1310325ad --- /dev/null +++ b/ext/oci8/tests/array_bind_001.phpt @@ -0,0 +1,69 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 1 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = ""; + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): OCI-21560: argument 3 is null, invalid, or out of range in %s on line %d + +Warning: oci_execute(): ORA-01008: not all variables bound in %s on line %d +array(1) { + [0]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/array_bind_002.phpt b/ext/oci8/tests/array_bind_002.phpt new file mode 100644 index 000000000..4c76df42f --- /dev/null +++ b/ext/oci8/tests/array_bind_002.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 2 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05"); + +oci_bind_array_by_name($statement, ":c1", $array, 0, 0, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Maximum array length must be greater than zero in %s on line %d + +Warning: oci_execute(): ORA-01008: not all variables bound in %s on line %d +array(5) { + [0]=> + string(9) "06-DEC-05" + [1]=> + string(9) "10-DEC-80" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "26-OCT-17" + [4]=> + string(9) "05-NOV-05" +} +Done diff --git a/ext/oci8/tests/array_bind_003.phpt b/ext/oci8/tests/array_bind_003.phpt new file mode 100644 index 000000000..497e46e49 --- /dev/null +++ b/ext/oci8/tests/array_bind_003.phpt @@ -0,0 +1,73 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 3 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): OCI_NO_DATA in %s on line %d +array(4) { + [0]=> + string(9) "06-DEC-05" + [1]=> + string(9) "10-DEC-80" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "26-OCT-17" +} +Done diff --git a/ext/oci8/tests/array_bind_004.phpt b/ext/oci8/tests/array_bind_004.phpt new file mode 100644 index 000000000..1ddf85149 --- /dev/null +++ b/ext/oci8/tests/array_bind_004.phpt @@ -0,0 +1,65 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 4 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): OCI_NO_DATA in %s on line %d +array(0) { +} +Done diff --git a/ext/oci8/tests/array_bind_005.phpt b/ext/oci8/tests/array_bind_005.phpt new file mode 100644 index 000000000..192d15563 --- /dev/null +++ b/ext/oci8/tests/array_bind_005.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 5 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("", "", "", "", ""); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" +} +Done diff --git a/ext/oci8/tests/array_bind_006.phpt b/ext/oci8/tests/array_bind_006.phpt new file mode 100644 index 000000000..e229dd872 --- /dev/null +++ b/ext/oci8/tests/array_bind_006.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name(), SQLT_CHR and default max_length +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = array("one", "two", "three", "four", "five"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/array_bind_007.phpt b/ext/oci8/tests/array_bind_007.phpt new file mode 100644 index 000000000..10c92a8e7 --- /dev/null +++ b/ext/oci8/tests/array_bind_007.phpt @@ -0,0 +1,77 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 7 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name NUMBER)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, -1); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Unknown or unsupported datatype given: -1 in %s on line %d + +Warning: oci_execute(): ORA-01008: not all variables bound in %s on line %d +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) +} +Done diff --git a/ext/oci8/tests/array_bind_008.phpt b/ext/oci8/tests/array_bind_008.phpt new file mode 100644 index 000000000..c44304c11 --- /dev/null +++ b/ext/oci8/tests/array_bind_008.phpt @@ -0,0 +1,78 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 8 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name NUMBER)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): ORA-06550: line %d, column %d: +PLS-00418: array bind type must match PL/SQL table row type +ORA-06550: line %d, column %d: +PL/SQL: Statement ignored in %s on line %d +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + [4]=> + string(1) "5" +} +Done diff --git a/ext/oci8/tests/array_bind_009.phpt b/ext/oci8/tests/array_bind_009.phpt new file mode 100644 index 000000000..8e83b0982 --- /dev/null +++ b/ext/oci8/tests/array_bind_009.phpt @@ -0,0 +1,17 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 9 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +var_dump(oci_bind_array_by_name($c, ":c1", $array, 5, 5, SQLT_CHR)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/array_bind_010.phpt b/ext/oci8/tests/array_bind_010.phpt new file mode 100644 index 000000000..a77ed913e --- /dev/null +++ b/ext/oci8/tests/array_bind_010.phpt @@ -0,0 +1,36 @@ +--TEST-- +oci_bind_array_by_name() and invalid values 8 +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$statement = oci_parse($c, 'SELECT user FROM v$session'); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): ORA-01036: illegal variable name/number in %s on line %d +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + [4]=> + string(1) "5" +} +Done diff --git a/ext/oci8/tests/array_bind_011.phpt b/ext/oci8/tests/array_bind_011.phpt new file mode 100644 index 000000000..e8e00a809 --- /dev/null +++ b/ext/oci8/tests/array_bind_011.phpt @@ -0,0 +1,67 @@ +--TEST-- +oci_bind_array_by_name(), SQLT_CHR, default max_length and empty array +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = array(); + +oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): You must provide max length value for empty arrays in %s on line %d + +Warning: oci_execute(): ORA-01008: not all variables bound in %s on line %d +array(0) { +} +Done diff --git a/ext/oci8/tests/array_bind_012.phpt b/ext/oci8/tests/array_bind_012.phpt new file mode 100644 index 000000000..2208f0b3b --- /dev/null +++ b/ext/oci8/tests/array_bind_012.phpt @@ -0,0 +1,26 @@ +--TEST-- +oci_bind_array_by_name(), SQLT_CHR, default max_length and empty array +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$statement = oci_parse($c, 'SELECT user FROM v$session'); + +$array = array(); + +oci_bind_array_by_name($statement, ":c1", $array, 5, -10, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_bind_array_by_name(): Invalid max length value (-10) in %s on line %d +array(0) { +} +Done diff --git a/ext/oci8/tests/array_bind_date.phpt b/ext/oci8/tests/array_bind_date.phpt new file mode 100644 index 000000000..63da558f9 --- /dev/null +++ b/ext/oci8/tests/array_bind_date.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_ODT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(9) "05-NOV-05" + [1]=> + string(9) "26-OCT-17" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "10-DEC-80" + [4]=> + string(9) "06-DEC-05" +} +Done diff --git a/ext/oci8/tests/array_bind_date1.phpt b/ext/oci8/tests/array_bind_date1.phpt new file mode 100644 index 000000000..ebf767570 --- /dev/null +++ b/ext/oci8/tests/array_bind_date1.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_ODT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name DATE)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05"); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_ODT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(9) "05-NOV-05" + [1]=> + string(9) "26-OCT-17" + [2]=> + string(9) "21-AUG-91" + [3]=> + string(9) "10-DEC-80" + [4]=> + string(9) "06-DEC-05" +} +Done diff --git a/ext/oci8/tests/array_bind_float.phpt b/ext/oci8/tests/array_bind_float.phpt new file mode 100644 index 000000000..1aafb2431 --- /dev/null +++ b/ext/oci8/tests/array_bind_float.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_FLT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name FLOAT)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF FLOAT INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_FLT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + float(5.9999) + [1]=> + float(4.2123) + [2]=> + float(3.4234) + [3]=> + float(2.5658) + [4]=> + float(1.243) +} +Done diff --git a/ext/oci8/tests/array_bind_float1.phpt b/ext/oci8/tests/array_bind_float1.phpt new file mode 100644 index 000000000..ead85890f --- /dev/null +++ b/ext/oci8/tests/array_bind_float1.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_FLT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name FLOAT)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF FLOAT INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_FLT); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + float(5.9999) + [1]=> + float(4.2123) + [2]=> + float(3.4234) + [3]=> + float(2.5658) + [4]=> + float(1.243) +} +Done diff --git a/ext/oci8/tests/array_bind_int.phpt b/ext/oci8/tests/array_bind_int.phpt new file mode 100644 index 000000000..3c8bfd4f5 --- /dev/null +++ b/ext/oci8/tests/array_bind_int.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_INT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name NUMBER)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_NUM); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +Done diff --git a/ext/oci8/tests/array_bind_int1.phpt b/ext/oci8/tests/array_bind_int1.phpt new file mode 100644 index 000000000..eb2072adc --- /dev/null +++ b/ext/oci8/tests/array_bind_int1.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_INT +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name NUMBER)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array(1,2,3,4,5); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_NUM); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +Done diff --git a/ext/oci8/tests/array_bind_str.phpt b/ext/oci8/tests/array_bind_str.phpt new file mode 100644 index 000000000..c8e1e0cdb --- /dev/null +++ b/ext/oci8/tests/array_bind_str.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_AVC +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("one", "two", "three", "four", "five"); + +oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/array_bind_str1.phpt b/ext/oci8/tests/array_bind_str1.phpt new file mode 100644 index 000000000..af4dbfe22 --- /dev/null +++ b/ext/oci8/tests/array_bind_str1.phpt @@ -0,0 +1,74 @@ +--TEST-- +oci_bind_array_by_name() and SQLT_AVC +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(20))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$create_pkg = " +CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS + TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER; + PROCEDURE iobind(c1 IN OUT ARRTYPE); +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg); +oci_execute($statement); + +$create_pkg_body = " +CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS + CURSOR CUR IS SELECT name FROM bind_test; + PROCEDURE iobind(c1 IN OUT ARRTYPE) IS + BEGIN + FOR i IN 1..5 LOOP + INSERT INTO bind_test VALUES (c1(i)); + END LOOP; + IF NOT CUR%ISOPEN THEN + OPEN CUR; + END IF; + FOR i IN REVERSE 1..5 LOOP + FETCH CUR INTO c1(i); + IF CUR%NOTFOUND THEN + CLOSE CUR; + EXIT; + END IF; + END LOOP; + END iobind; +END ARRAYBINDPKG1;"; +$statement = oci_parse($c, $create_pkg_body); +oci_execute($statement); + +$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); + +$array = Array("one", "two", "three", "four", "five"); + +oci_bind_array_by_name($statement, ":c1", $array, 10, 20, SQLT_CHR); + +oci_execute($statement); + +var_dump($array); + +echo "Done\n"; +?> +--EXPECT-- +array(5) { + [0]=> + string(4) "five" + [1]=> + string(4) "four" + [2]=> + string(5) "three" + [3]=> + string(3) "two" + [4]=> + string(3) "one" +} +Done diff --git a/ext/oci8/tests/bind_empty.phpt b/ext/oci8/tests/bind_empty.phpt new file mode 100644 index 000000000..dc993016a --- /dev/null +++ b/ext/oci8/tests/bind_empty.phpt @@ -0,0 +1,39 @@ +--TEST-- +binding empty values +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table bind_test(name VARCHAR(10))"; +$statement = oci_parse($c, $create); +oci_execute($statement); + + +$name = null; +$stmt = oci_parse($c, "UPDATE bind_test SET name=:name"); +oci_bind_by_name($stmt, ":name", &$name); + +$res = oci_execute($stmt); + +$name = ""; +$stmt = oci_parse($c, "UPDATE bind_test SET name=:name"); +oci_bind_by_name($stmt, ":name", &$name); + +$res = oci_execute($stmt); + +$drop = "DROP table bind_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +Done diff --git a/ext/oci8/tests/bug26133.phpt b/ext/oci8/tests/bug26133.phpt index d3f0ed9bf..df319feb0 100644 --- a/ext/oci8/tests/bug26133.phpt +++ b/ext/oci8/tests/bug26133.phpt @@ -1,36 +1,34 @@ --TEST-- Bug #26133 (ocifreedesc() segfault) --SKIPIF-- -<?php - require 'skipif.inc'; -?> +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> --FILE-- <?php - require 'connect.inc'; - require 'create_table.inc'; - - if ($connection) { + + require dirname(__FILE__).'/connect.inc'; + require dirname(__FILE__).'/create_table.inc'; + + if ($c) { $ora_sql = "INSERT INTO - ".$schema."php_test_table (id, value) + ".$schema.$table_name." (id, value) VALUES ('1','1') RETURNING ROWID INTO :v_rowid "; - $statement = OCIParse($connection,$ora_sql); - $rowid = OCINewDescriptor($connection,OCI_D_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($connection); + OCICommit($c); } OCIFreeStatement($statement); $rowid->free(); } - require 'drop_table.inc'; + require dirname(__FILE__).'/drop_table.inc'; echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- Done - diff --git a/ext/oci8/tests/bug27303.phpt b/ext/oci8/tests/bug27303.phpt new file mode 100644 index 000000000..191cdffe6 --- /dev/null +++ b/ext/oci8/tests/bug27303.phpt @@ -0,0 +1,252 @@ +--TEST-- +bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +//$mybv = INITMYBV; // Uncomment this for the 2nd test only +$r = OCIBindByName($stid, ':MYBV', $mybv /*, 5 */); // Uncomment this for the 3rd test only +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(3) "100" +string(3) "101" +string(3) "102" +string(3) "103" +string(3) "104" +string(3) "105" +string(3) "106" +string(3) "107" +string(3) "108" +string(3) "109" +string(3) "110" +string(3) "111" +string(3) "112" +string(3) "113" +string(3) "114" +string(3) "115" +string(3) "116" +string(3) "117" +string(3) "118" +string(3) "119" +string(3) "120" +string(3) "121" +string(3) "122" +string(3) "123" +string(3) "124" +string(3) "125" +string(3) "126" +string(3) "127" +string(3) "128" +string(3) "129" +string(3) "130" +string(3) "131" +string(3) "132" +string(3) "133" +string(3) "134" +string(3) "135" +string(3) "136" +string(3) "137" +string(3) "138" +string(3) "139" +string(3) "140" +string(3) "141" +string(3) "142" +string(3) "143" +string(3) "144" +string(3) "145" +string(3) "146" +string(3) "147" +string(3) "148" +string(3) "149" +string(3) "150" +string(3) "151" +string(3) "152" +string(3) "153" +string(3) "154" +string(3) "155" +string(3) "156" +string(3) "157" +string(3) "158" +string(3) "159" +string(3) "160" +string(3) "161" +string(3) "162" +string(3) "163" +string(3) "164" +string(3) "165" +string(3) "166" +string(3) "167" +string(3) "168" +string(3) "169" +string(3) "170" +string(3) "171" +string(3) "172" +string(3) "173" +string(3) "174" +string(3) "175" +string(3) "176" +string(3) "177" +string(3) "178" +string(3) "179" +string(3) "180" +string(3) "181" +string(3) "182" +string(3) "183" +string(3) "184" +string(3) "185" +string(3) "186" +string(3) "187" +string(3) "188" +string(3) "189" +string(3) "190" +string(3) "191" +string(3) "192" +string(3) "193" +string(3) "194" +string(3) "195" +string(3) "196" +string(3) "197" +string(3) "198" +string(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt new file mode 100644 index 000000000..67f3552f1 --- /dev/null +++ b/ext/oci8/tests/bug27303_2.phpt @@ -0,0 +1,252 @@ +--TEST-- +bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$mybv = INITMYBV; // Uncomment this for the 2nd test only +$r = OCIBindByName($stid, ':MYBV', $mybv /*, 5 */); // Uncomment this for the 3rd test only +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(3) "100" +string(3) "101" +string(3) "102" +string(3) "103" +string(3) "104" +string(3) "105" +string(3) "106" +string(3) "107" +string(3) "108" +string(3) "109" +string(3) "110" +string(3) "111" +string(3) "112" +string(3) "113" +string(3) "114" +string(3) "115" +string(3) "116" +string(3) "117" +string(3) "118" +string(3) "119" +string(3) "120" +string(3) "121" +string(3) "122" +string(3) "123" +string(3) "124" +string(3) "125" +string(3) "126" +string(3) "127" +string(3) "128" +string(3) "129" +string(3) "130" +string(3) "131" +string(3) "132" +string(3) "133" +string(3) "134" +string(3) "135" +string(3) "136" +string(3) "137" +string(3) "138" +string(3) "139" +string(3) "140" +string(3) "141" +string(3) "142" +string(3) "143" +string(3) "144" +string(3) "145" +string(3) "146" +string(3) "147" +string(3) "148" +string(3) "149" +string(3) "150" +string(3) "151" +string(3) "152" +string(3) "153" +string(3) "154" +string(3) "155" +string(3) "156" +string(3) "157" +string(3) "158" +string(3) "159" +string(3) "160" +string(3) "161" +string(3) "162" +string(3) "163" +string(3) "164" +string(3) "165" +string(3) "166" +string(3) "167" +string(3) "168" +string(3) "169" +string(3) "170" +string(3) "171" +string(3) "172" +string(3) "173" +string(3) "174" +string(3) "175" +string(3) "176" +string(3) "177" +string(3) "178" +string(3) "179" +string(3) "180" +string(3) "181" +string(3) "182" +string(3) "183" +string(3) "184" +string(3) "185" +string(3) "186" +string(3) "187" +string(3) "188" +string(3) "189" +string(3) "190" +string(3) "191" +string(3) "192" +string(3) "193" +string(3) "194" +string(3) "195" +string(3) "196" +string(3) "197" +string(3) "198" +string(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_3.phpt b/ext/oci8/tests/bug27303_3.phpt new file mode 100644 index 000000000..3a8982d30 --- /dev/null +++ b/ext/oci8/tests/bug27303_3.phpt @@ -0,0 +1,252 @@ +--TEST-- +bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +$mybv = INITMYBV; // Uncomment this for the 2nd test only +$r = OCIBindByName($stid, ':MYBV', $mybv, 5, SQLT_INT); // Uncomment this for the 3rd test only +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(2) +int(3) +int(4) +int(5) +int(6) +int(7) +int(8) +int(9) +int(10) +int(11) +int(12) +int(13) +int(14) +int(15) +int(16) +int(17) +int(18) +int(19) +int(20) +int(21) +int(22) +int(23) +int(24) +int(25) +int(26) +int(27) +int(28) +int(29) +int(30) +int(31) +int(32) +int(33) +int(34) +int(35) +int(36) +int(37) +int(38) +int(39) +int(40) +int(41) +int(42) +int(43) +int(44) +int(45) +int(46) +int(47) +int(48) +int(49) +int(50) +int(51) +int(52) +int(53) +int(54) +int(55) +int(56) +int(57) +int(58) +int(59) +int(60) +int(61) +int(62) +int(63) +int(64) +int(65) +int(66) +int(67) +int(68) +int(69) +int(70) +int(71) +int(72) +int(73) +int(74) +int(75) +int(76) +int(77) +int(78) +int(79) +int(80) +int(81) +int(82) +int(83) +int(84) +int(85) +int(86) +int(87) +int(88) +int(89) +int(90) +int(91) +int(92) +int(93) +int(94) +int(95) +int(96) +int(97) +int(98) +int(99) +int(100) +int(101) +int(102) +int(103) +int(104) +int(105) +int(106) +int(107) +int(108) +int(109) +int(110) +int(111) +int(112) +int(113) +int(114) +int(115) +int(116) +int(117) +int(118) +int(119) +int(120) +int(121) +int(122) +int(123) +int(124) +int(125) +int(126) +int(127) +int(128) +int(129) +int(130) +int(131) +int(132) +int(133) +int(134) +int(135) +int(136) +int(137) +int(138) +int(139) +int(140) +int(141) +int(142) +int(143) +int(144) +int(145) +int(146) +int(147) +int(148) +int(149) +int(150) +int(151) +int(152) +int(153) +int(154) +int(155) +int(156) +int(157) +int(158) +int(159) +int(160) +int(161) +int(162) +int(163) +int(164) +int(165) +int(166) +int(167) +int(168) +int(169) +int(170) +int(171) +int(172) +int(173) +int(174) +int(175) +int(176) +int(177) +int(178) +int(179) +int(180) +int(181) +int(182) +int(183) +int(184) +int(185) +int(186) +int(187) +int(188) +int(189) +int(190) +int(191) +int(192) +int(193) +int(194) +int(195) +int(196) +int(197) +int(198) +int(199) +Done diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt new file mode 100644 index 000000000..8ba4ef44b --- /dev/null +++ b/ext/oci8/tests/bug27303_4.phpt @@ -0,0 +1,252 @@ +--TEST-- +bug #27303 (OCIBindByName binds numeric PHP values as characters) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$create_st = array(); +$create_st[] = "drop sequence myseq"; +$create_st[] = "drop table mytab"; +$create_st[] = "create sequence myseq"; +$create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +define('MYLIMIT', 200); +define('INITMYBV', 11); + +$stmt = "insert into mytab (mydata, seqcol) values ('Some data', myseq.nextval) returning seqcol into :mybv"; + +$stid = OCIParse($c, $stmt); +if (!$stid) { echo "Parse error"; die; } + +//$mybv = INITMYBV; // Uncomment this for the 2nd test only +$r = OCIBindByName($stid, ':MYBV', $mybv, 0 ); // Uncomment this for the 3rd test only +if (!$r) { echo "Bind error"; die; } + +for ($i = 1; $i < MYLIMIT; $i++) { + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); +} + +OCICommit($c); + +$drop_st = array(); +$drop_st[] = "drop sequence myseq"; +$drop_st[] = "drop table mytab"; + +foreach ($create_st as $statement) { + $stmt = oci_parse($c, $statement); + oci_execute($stmt); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(2) "10" +string(2) "11" +string(2) "12" +string(2) "13" +string(2) "14" +string(2) "15" +string(2) "16" +string(2) "17" +string(2) "18" +string(2) "19" +string(2) "20" +string(2) "21" +string(2) "22" +string(2) "23" +string(2) "24" +string(2) "25" +string(2) "26" +string(2) "27" +string(2) "28" +string(2) "29" +string(2) "30" +string(2) "31" +string(2) "32" +string(2) "33" +string(2) "34" +string(2) "35" +string(2) "36" +string(2) "37" +string(2) "38" +string(2) "39" +string(2) "40" +string(2) "41" +string(2) "42" +string(2) "43" +string(2) "44" +string(2) "45" +string(2) "46" +string(2) "47" +string(2) "48" +string(2) "49" +string(2) "50" +string(2) "51" +string(2) "52" +string(2) "53" +string(2) "54" +string(2) "55" +string(2) "56" +string(2) "57" +string(2) "58" +string(2) "59" +string(2) "60" +string(2) "61" +string(2) "62" +string(2) "63" +string(2) "64" +string(2) "65" +string(2) "66" +string(2) "67" +string(2) "68" +string(2) "69" +string(2) "70" +string(2) "71" +string(2) "72" +string(2) "73" +string(2) "74" +string(2) "75" +string(2) "76" +string(2) "77" +string(2) "78" +string(2) "79" +string(2) "80" +string(2) "81" +string(2) "82" +string(2) "83" +string(2) "84" +string(2) "85" +string(2) "86" +string(2) "87" +string(2) "88" +string(2) "89" +string(2) "90" +string(2) "91" +string(2) "92" +string(2) "93" +string(2) "94" +string(2) "95" +string(2) "96" +string(2) "97" +string(2) "98" +string(2) "99" +string(3) "100" +string(3) "101" +string(3) "102" +string(3) "103" +string(3) "104" +string(3) "105" +string(3) "106" +string(3) "107" +string(3) "108" +string(3) "109" +string(3) "110" +string(3) "111" +string(3) "112" +string(3) "113" +string(3) "114" +string(3) "115" +string(3) "116" +string(3) "117" +string(3) "118" +string(3) "119" +string(3) "120" +string(3) "121" +string(3) "122" +string(3) "123" +string(3) "124" +string(3) "125" +string(3) "126" +string(3) "127" +string(3) "128" +string(3) "129" +string(3) "130" +string(3) "131" +string(3) "132" +string(3) "133" +string(3) "134" +string(3) "135" +string(3) "136" +string(3) "137" +string(3) "138" +string(3) "139" +string(3) "140" +string(3) "141" +string(3) "142" +string(3) "143" +string(3) "144" +string(3) "145" +string(3) "146" +string(3) "147" +string(3) "148" +string(3) "149" +string(3) "150" +string(3) "151" +string(3) "152" +string(3) "153" +string(3) "154" +string(3) "155" +string(3) "156" +string(3) "157" +string(3) "158" +string(3) "159" +string(3) "160" +string(3) "161" +string(3) "162" +string(3) "163" +string(3) "164" +string(3) "165" +string(3) "166" +string(3) "167" +string(3) "168" +string(3) "169" +string(3) "170" +string(3) "171" +string(3) "172" +string(3) "173" +string(3) "174" +string(3) "175" +string(3) "176" +string(3) "177" +string(3) "178" +string(3) "179" +string(3) "180" +string(3) "181" +string(3) "182" +string(3) "183" +string(3) "184" +string(3) "185" +string(3) "186" +string(3) "187" +string(3) "188" +string(3) "189" +string(3) "190" +string(3) "191" +string(3) "192" +string(3) "193" +string(3) "194" +string(3) "195" +string(3) "196" +string(3) "197" +string(3) "198" +string(3) "199" +Done diff --git a/ext/oci8/tests/bug32325.phpt b/ext/oci8/tests/bug32325.phpt new file mode 100644 index 000000000..6bfcd404e --- /dev/null +++ b/ext/oci8/tests/bug32325.phpt @@ -0,0 +1,39 @@ +--TEST-- +bug #32325 (Can't 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; + end;"; + +$stmt = oci_parse($c, $sql); + +oci_bind_by_name($stmt, ":list", $collection, -1, OCI_B_NTY); +oci_execute($stmt); + +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); + +echo "Done\n"; +?> +--EXPECTF-- +int(4) +float(2) +float(3) +Done diff --git a/ext/oci8/tests/close.phpt b/ext/oci8/tests/close.phpt new file mode 100644 index 000000000..55bb4ea36 --- /dev/null +++ b/ext/oci8/tests/close.phpt @@ -0,0 +1,17 @@ +--TEST-- +connect/close/connect +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +oci_close($c); + +oci_connect($user, $password, $dbase); + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/ext/oci8/tests/coll_001.phpt b/ext/oci8/tests/coll_001.phpt new file mode 100644 index 000000000..57d3cf1b4 --- /dev/null +++ b/ext/oci8/tests/coll_001.phpt @@ -0,0 +1,27 @@ +--TEST-- +oci_new_collection() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump(oci_new_collection($c, $type_name)); +var_dump(oci_new_collection($c, "NONEXISTENT")); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} + +Warning: oci_new_collection(): OCI-22303: type ""."NONEXISTENT" not found in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_002.phpt b/ext/oci8/tests/coll_002.phpt new file mode 100644 index 000000000..6d3051989 --- /dev/null +++ b/ext/oci8/tests/coll_002.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_new_collection() + free() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = oci_new_collection($c, $type_name)); + +var_dump($coll1->free()); +var_dump($coll1->size()); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: OCI-Collection::size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_002_func.phpt b/ext/oci8/tests/coll_002_func.phpt new file mode 100644 index 000000000..58e641ee2 --- /dev/null +++ b/ext/oci8/tests/coll_002_func.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_new_collection() + free() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = oci_new_collection($c, $type_name)); + +var_dump(oci_free_collection($coll1)); +var_dump(oci_collection_size($coll1)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: oci_collection_size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_003.phpt b/ext/oci8/tests/coll_003.phpt new file mode 100644 index 000000000..b5236ef6f --- /dev/null +++ b/ext/oci8/tests/coll_003.phpt @@ -0,0 +1,34 @@ +--TEST-- +collection methods +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); + +var_dump($coll1->size()); +var_dump($coll1->max()); +var_dump($coll1->trim(3)); +var_dump($coll1->append(1)); +var_dump($coll1->getElem(0)); +var_dump($coll1->assignElem(0,2)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +int(0) +int(0) + +Warning: OCI-Collection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +bool(false) +bool(true) +float(1) +bool(true) +Done diff --git a/ext/oci8/tests/coll_003_func.phpt b/ext/oci8/tests/coll_003_func.phpt new file mode 100644 index 000000000..f5c6dc7f3 --- /dev/null +++ b/ext/oci8/tests/coll_003_func.phpt @@ -0,0 +1,34 @@ +--TEST-- +collection methods +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); + +var_dump(oci_collection_size($coll1)); +var_dump(oci_collection_max($coll1)); +var_dump(oci_collection_trim($coll1, 3)); +var_dump(oci_collection_append($coll1, 1)); +var_dump(oci_collection_element_get($coll1, 0)); +var_dump(oci_collection_element_assign($coll1, 0, 2)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +int(0) +int(0) + +Warning: oci_collection_trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +bool(false) +bool(true) +float(1) +bool(true) +Done diff --git a/ext/oci8/tests/coll_004.phpt b/ext/oci8/tests/coll_004.phpt new file mode 100644 index 000000000..eb2ac7e26 --- /dev/null +++ b/ext/oci8/tests/coll_004.phpt @@ -0,0 +1,29 @@ +--TEST-- +oci_collection_assign() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); +$coll2 = oci_new_collection($c, $type_name); + +var_dump($coll1->append(1)); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(1) +Done diff --git a/ext/oci8/tests/coll_004_func.phpt b/ext/oci8/tests/coll_004_func.phpt new file mode 100644 index 000000000..57dff2eb3 --- /dev/null +++ b/ext/oci8/tests/coll_004_func.phpt @@ -0,0 +1,29 @@ +--TEST-- +oci_collection_assign() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = oci_new_collection($c, $type_name); +$coll2 = oci_new_collection($c, $type_name); + +var_dump(oci_collection_append($coll1, 1)); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(1) +Done diff --git a/ext/oci8/tests/coll_005.phpt b/ext/oci8/tests/coll_005.phpt new file mode 100644 index 000000000..0f4006996 --- /dev/null +++ b/ext/oci8/tests/coll_005.phpt @@ -0,0 +1,27 @@ +--TEST-- +ocinewcollection() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump(ocinewcollection($c, $type_name)); +var_dump(ocinewcollection($c, "NONEXISTENT")); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} + +Warning: ocinewcollection(): OCI-22303: type ""."NONEXISTENT" not found in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_006.phpt b/ext/oci8/tests/coll_006.phpt new file mode 100644 index 000000000..cf258cbe3 --- /dev/null +++ b/ext/oci8/tests/coll_006.phpt @@ -0,0 +1,30 @@ +--TEST-- +ocinewcollection() + free() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = ocinewcollection($c, $type_name)); + +var_dump($coll1->free()); +var_dump($coll1->size()); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: OCI-Collection::size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_006_func.phpt b/ext/oci8/tests/coll_006_func.phpt new file mode 100644 index 000000000..56707d608 --- /dev/null +++ b/ext/oci8/tests/coll_006_func.phpt @@ -0,0 +1,30 @@ +--TEST-- +ocinewcollection() + free() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +var_dump($coll1 = ocinewcollection($c, $type_name)); + +var_dump(oci_free_collection($coll1)); +var_dump(oci_collection_size($coll1)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +object(OCI-Collection)#%d (1) { + ["collection"]=> + resource(%d) of type (oci8 collection) +} +bool(true) + +Warning: oci_collection_size(): %d is not a valid oci8 collection resource in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/coll_007.phpt b/ext/oci8/tests/coll_007.phpt new file mode 100644 index 000000000..31e10c065 --- /dev/null +++ b/ext/oci8/tests/coll_007.phpt @@ -0,0 +1,34 @@ +--TEST-- +collection methods +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->size()); +var_dump($coll1->max()); +var_dump($coll1->trim(3)); +var_dump($coll1->append(1)); +var_dump($coll1->getElem(0)); +var_dump($coll1->assignElem(0,2)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +int(0) +int(0) + +Warning: OCI-Collection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +bool(false) +bool(true) +float(1) +bool(true) +Done diff --git a/ext/oci8/tests/coll_008.phpt b/ext/oci8/tests/coll_008.phpt new file mode 100644 index 000000000..57d44cc9a --- /dev/null +++ b/ext/oci8/tests/coll_008.phpt @@ -0,0 +1,29 @@ +--TEST-- +ocicollassign() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__)."/create_type.inc"; + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(1)); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(1) +Done diff --git a/ext/oci8/tests/coll_009.phpt b/ext/oci8/tests/coll_009.phpt new file mode 100644 index 000000000..296d6493e --- /dev/null +++ b/ext/oci8/tests/coll_009.phpt @@ -0,0 +1,42 @@ +--TEST-- +collections and wrong dates +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("2005-07-28")); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +Warning: OCI-Collection::append(): OCI-01861: literal does not match format string in %s on line %d +bool(false) +bool(true) +bool(false) +Done diff --git a/ext/oci8/tests/coll_009_func.phpt b/ext/oci8/tests/coll_009_func.phpt new file mode 100644 index 000000000..3ed416ce0 --- /dev/null +++ b/ext/oci8/tests/coll_009_func.phpt @@ -0,0 +1,42 @@ +--TEST-- +collections and wrong dates +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "2005-07-28")); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +Warning: oci_collection_append(): OCI-01861: literal does not match format string in %s on line %d +bool(false) +bool(true) +bool(false) +Done diff --git a/ext/oci8/tests/coll_010.phpt b/ext/oci8/tests/coll_010.phpt new file mode 100644 index 000000000..6f72dd16c --- /dev/null +++ b/ext/oci8/tests/coll_010.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and nulls +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(null)); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_010_func.phpt b/ext/oci8/tests/coll_010_func.phpt new file mode 100644 index 000000000..7b63a276f --- /dev/null +++ b/ext/oci8/tests/coll_010_func.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and nulls +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, null)); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_011.phpt b/ext/oci8/tests/coll_011.phpt new file mode 100644 index 000000000..7d805d3f7 --- /dev/null +++ b/ext/oci8/tests/coll_011.phpt @@ -0,0 +1,43 @@ +--TEST-- +collections and strings +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("string")); +var_dump($coll1->append("string")); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +string(6) "string" +Done diff --git a/ext/oci8/tests/coll_011_func.phpt b/ext/oci8/tests/coll_011_func.phpt new file mode 100644 index 000000000..dca640e84 --- /dev/null +++ b/ext/oci8/tests/coll_011_func.phpt @@ -0,0 +1,43 @@ +--TEST-- +collections and strings +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "string")); +var_dump(oci_collection_append($coll1, "string")); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +string(6) "string" +Done diff --git a/ext/oci8/tests/coll_012.phpt b/ext/oci8/tests/coll_012.phpt new file mode 100644 index 000000000..543dafd90 --- /dev/null +++ b/ext/oci8/tests/coll_012.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and correct dates +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("28-JUL-05")); + +var_dump($coll2->assign($coll1)); + +var_dump($coll2->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "28-JUL-05" +Done diff --git a/ext/oci8/tests/coll_012_func.phpt b/ext/oci8/tests/coll_012_func.phpt new file mode 100644 index 000000000..fd1019e41 --- /dev/null +++ b/ext/oci8/tests/coll_012_func.phpt @@ -0,0 +1,41 @@ +--TEST-- +collections and correct dates +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); +$coll2 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "28-JUL-05")); + +var_dump(oci_collection_assign($coll2, $coll1)); + +var_dump(oci_collection_element_get($coll2, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "28-JUL-05" +Done diff --git a/ext/oci8/tests/coll_013.phpt b/ext/oci8/tests/coll_013.phpt new file mode 100644 index 000000000..00d88bb9a --- /dev/null +++ b/ext/oci8/tests/coll_013.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and correct dates (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("28-JUL-05")); +var_dump($coll1->assignElem(0,"01-JAN-05")); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "01-JAN-05" +Done diff --git a/ext/oci8/tests/coll_013_func.phpt b/ext/oci8/tests/coll_013_func.phpt new file mode 100644 index 000000000..0d01bc174 --- /dev/null +++ b/ext/oci8/tests/coll_013_func.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and correct dates (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "28-JUL-05")); +var_dump(oci_collection_element_assign($coll1, 0, "01-JAN-05")); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "01-JAN-05" +Done diff --git a/ext/oci8/tests/coll_014.phpt b/ext/oci8/tests/coll_014.phpt new file mode 100644 index 000000000..8458525ae --- /dev/null +++ b/ext/oci8/tests/coll_014.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and strings (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("striing")); +var_dump($coll1->assignElem(0,"blah")); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(4) "blah" +Done diff --git a/ext/oci8/tests/coll_014_func.phpt b/ext/oci8/tests/coll_014_func.phpt new file mode 100644 index 000000000..a0fe555b6 --- /dev/null +++ b/ext/oci8/tests/coll_014_func.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and strings (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "striing")); +var_dump(oci_collection_element_assign($coll1, 0,"blah")); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(4) "blah" +Done diff --git a/ext/oci8/tests/coll_015.phpt b/ext/oci8/tests/coll_015.phpt new file mode 100644 index 000000000..64b0aea10 --- /dev/null +++ b/ext/oci8/tests/coll_015.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and numbers (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(1)); +var_dump($coll1->assignElem(0,2345)); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(2345) +Done diff --git a/ext/oci8/tests/coll_015_func.phpt b/ext/oci8/tests/coll_015_func.phpt new file mode 100644 index 000000000..eeed7839a --- /dev/null +++ b/ext/oci8/tests/coll_015_func.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and numbers (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, 1)); +var_dump(oci_collection_element_assign($coll1,0,2345)); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +float(2345) +Done diff --git a/ext/oci8/tests/coll_016.phpt b/ext/oci8/tests/coll_016.phpt new file mode 100644 index 000000000..1a57a104e --- /dev/null +++ b/ext/oci8/tests/coll_016.phpt @@ -0,0 +1,48 @@ +--TEST-- +collections and negative/too big element indexes +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append(1)); +var_dump($coll1->assignElem(-1,2345)); +var_dump($coll1->assignElem(5000,2345)); +var_dump($coll1->getElem(-1)); +var_dump($coll1->getElem(-100)); +var_dump($coll1->getElem(500)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +bool(true) + +Warning: OCI-Collection::assignelem(): OCI-22165: given index [4294967295] must be in the range of 0 to [0] in %s on line %d +bool(false) + +Warning: OCI-Collection::assignelem(): OCI-22165: given index [5000] must be in the range of 0 to [0] in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) +Done diff --git a/ext/oci8/tests/coll_016_func.phpt b/ext/oci8/tests/coll_016_func.phpt new file mode 100644 index 000000000..e090ca19e --- /dev/null +++ b/ext/oci8/tests/coll_016_func.phpt @@ -0,0 +1,48 @@ +--TEST-- +collections and negative/too big element indexes +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, 1)); +var_dump(oci_collection_element_assign($coll1,-1,2345)); +var_dump(oci_collection_element_assign($coll1,5000,2345)); +var_dump(oci_collection_element_get($coll1, -1)); +var_dump(oci_collection_element_get($coll1, -100)); +var_dump(oci_collection_element_get($coll1, 500)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECTF-- +bool(true) + +Warning: oci_collection_element_assign(): OCI-22165: given index [4294967295] must be in the range of 0 to [0] in %s on line %d +bool(false) + +Warning: oci_collection_element_assign(): OCI-22165: given index [5000] must be in the range of 0 to [0] in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) +Done diff --git a/ext/oci8/tests/coll_017.phpt b/ext/oci8/tests/coll_017.phpt new file mode 100644 index 000000000..42347ba6f --- /dev/null +++ b/ext/oci8/tests/coll_017.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and nulls (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump($coll1->append("string")); +var_dump($coll1->assignElem(0, null)); +var_dump($coll1->getElem(0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/coll_017_func.phpt b/ext/oci8/tests/coll_017_func.phpt new file mode 100644 index 000000000..914844ae6 --- /dev/null +++ b/ext/oci8/tests/coll_017_func.phpt @@ -0,0 +1,38 @@ +--TEST-- +collections and nulls (2) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$ora_sql = "DROP TYPE + ".$type_name." + "; + +$statement = OCIParse($c,$ora_sql); +@OCIExecute($statement); + +$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR(10)"; + +$statement = OCIParse($c,$ora_sql); +OCIExecute($statement); + + +$coll1 = ocinewcollection($c, $type_name); + +var_dump(oci_collection_append($coll1, "string")); +var_dump(oci_collection_element_assign($coll1, 0, null)); +var_dump(oci_collection_element_get($coll1, 0)); + +echo "Done\n"; + +require dirname(__FILE__)."/drop_type.inc"; + +?> +--EXPECT-- +bool(true) +bool(true) +NULL +Done diff --git a/ext/oci8/tests/commit.phpt b/ext/oci8/tests/commit.phpt new file mode 100644 index 000000000..3bef318c8 --- /dev/null +++ b/ext/oci8/tests/commit.phpt @@ -0,0 +1,148 @@ +--TEST-- +oci_commit()/oci_rollback() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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, OCI_DEFAULT)) { + die("oci_execute(insert) failed!\n"); + } +} + +var_dump(oci_rollback($c)); + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($select = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +/* oci_fetch_all */ +if (!oci_execute($select)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($select, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$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, OCI_DEFAULT)) { + die("oci_execute(insert) failed!\n"); + } +} + +var_dump(oci_commit($c)); + +/* oci_fetch_all */ +if (!oci_execute($select)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($select, $all)); +var_dump($all); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(0) +array(5) { + ["ID"]=> + array(0) { + } + ["VALUE"]=> + array(0) { + } + ["BLOB"]=> + array(0) { + } + ["CLOB"]=> + array(0) { + } + ["STRING"]=> + array(0) { + } +} +bool(true) +int(4) +array(5) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + [3]=> + string(1) "1" + } + ["VALUE"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + [3]=> + string(1) "1" + } + ["BLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + ["CLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + ["STRING"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/commit_old.phpt b/ext/oci8/tests/commit_old.phpt new file mode 100644 index 000000000..196e0650c --- /dev/null +++ b/ext/oci8/tests/commit_old.phpt @@ -0,0 +1,146 @@ +--TEST-- +ocicommit()/ocirollback() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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 = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s, OCI_DEFAULT)) { + die("ociexecute(insert) failed!\n"); + } +} + +var_dump(ocirollback($c)); + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($select = ociparse($c, $select_sql))) { + die("ociparse(select) failed!\n"); +} + +if (!oci_execute($select)) { + die("ociexecute(select) failed!\n"); +} +var_dump(ocifetchstatement($select, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!ociexecute($s)) { + die("ociexecute(select) failed!\n"); +} + +$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; + +if (!($s = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s, OCI_DEFAULT)) { + die("ociexecute(insert) failed!\n"); + } +} + +var_dump(ocicommit($c)); + +if (!ociexecute($select)) { + die("ociexecute(select) failed!\n"); +} +var_dump(ocifetchstatement($select, $all)); +var_dump($all); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(0) +array(5) { + ["ID"]=> + array(0) { + } + ["VALUE"]=> + array(0) { + } + ["BLOB"]=> + array(0) { + } + ["CLOB"]=> + array(0) { + } + ["STRING"]=> + array(0) { + } +} +bool(true) +int(4) +array(5) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + [3]=> + string(1) "1" + } + ["VALUE"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + [3]=> + string(1) "1" + } + ["BLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + ["CLOB"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } + ["STRING"]=> + array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/connect.inc b/ext/oci8/tests/connect.inc index a0013e20d..887c8fdaa 100644 --- a/ext/oci8/tests/connect.inc +++ b/ext/oci8/tests/connect.inc @@ -4,29 +4,27 @@ * Please, change user, password and dbase to match your configuration. * * */ - -$user = "user"; -$password = "pass"; -$dbase = "base"; + +$user = "system"; +$password = "system"; +$dbase = "oracle"; /* * You should have privileges to create tables in this schema * * */ - -$schema = "system"; - /* - * Remove the last line in skipif.inc to run tests - * - * */ - +$schema = "system"; +*/ +$table_name = "tb".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5); +$type_name = strtoupper("tp".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5)); + if (!empty($dbase)) { - $connection = ocilogon($user,$password,$dbase); + $c = ocilogon($user,$password,$dbase); } else { - $connection = ocilogon($user,$password); + $c = ocilogon($user,$password); } if (!empty($schema)) { diff --git a/ext/oci8/tests/connect.phpt b/ext/oci8/tests/connect.phpt new file mode 100644 index 000000000..6ce4c533b --- /dev/null +++ b/ext/oci8/tests/connect.phpt @@ -0,0 +1,22 @@ +--TEST-- +oci_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/connect_1.phpt b/ext/oci8/tests/connect_1.phpt new file mode 100644 index 000000000..647a92cee --- /dev/null +++ b/ext/oci8/tests/connect_1.phpt @@ -0,0 +1,35 @@ +--TEST-- +oci_pconnect() & oci_new_connect() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c1 = oci_pconnect($user, $password, $dbase)); +} +else { + var_dump($c1 = oci_pconnect($user, $password)); +} + +if (!empty($dbase)) { + var_dump($c2 = oci_new_connect($user, $password, $dbase)); +} +else { + var_dump($c2 = oci_new_connect($user, $password)); +} + +var_dump(oci_close($c1)); +var_dump(ocilogoff($c2)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +bool(true) +bool(true) +Done diff --git a/ext/oci8/tests/connect_1_old.phpt b/ext/oci8/tests/connect_1_old.phpt new file mode 100644 index 000000000..8210b82d6 --- /dev/null +++ b/ext/oci8/tests/connect_1_old.phpt @@ -0,0 +1,35 @@ +--TEST-- +ociplogon() & ocinlogon() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c1 = ociplogon($user, $password, $dbase)); +} +else { + var_dump($c1 = ociplogon($user, $password)); +} + +if (!empty($dbase)) { + var_dump($c2 = ocinlogon($user, $password, $dbase)); +} +else { + var_dump($c2 = ocinlogon($user, $password)); +} + +var_dump(ocilogoff($c1)); +var_dump(ocilogoff($c2)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +bool(true) +bool(true) +Done diff --git a/ext/oci8/tests/connect_old.phpt b/ext/oci8/tests/connect_old.phpt new file mode 100644 index 000000000..55f1734a5 --- /dev/null +++ b/ext/oci8/tests/connect_old.phpt @@ -0,0 +1,22 @@ +--TEST-- +ocilogon() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt new file mode 100644 index 000000000..513d60cef --- /dev/null +++ b/ext/oci8/tests/connect_without_oracle_home.phpt @@ -0,0 +1,25 @@ +--TEST-- +oci_connect() without ORACLE_HOME set (OCIServerAttach() segfaults) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: ocilogon(): _oci_open_server failed, check ORACLE_HOME and NLS_LANG variables: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in %sconnect.inc on line %d + +Warning: oci_connect(): _oci_open_server failed, check ORACLE_HOME and NLS_LANG variables: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in %sconnect_without_oracle_home.php on line %d +bool(false) +Done diff --git a/ext/oci8/tests/connect_without_oracle_home_old.phpt b/ext/oci8/tests/connect_without_oracle_home_old.phpt new file mode 100644 index 000000000..68b11de15 --- /dev/null +++ b/ext/oci8/tests/connect_without_oracle_home_old.phpt @@ -0,0 +1,25 @@ +--TEST-- +ocilogon() without ORACLE_HOME set (OCIServerAttach() segfaults) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: ocilogon(): _oci_open_server failed, check ORACLE_HOME and NLS_LANG variables: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in %sconnect.inc on line %d + +Warning: oci_connect(): _oci_open_server failed, check ORACLE_HOME and NLS_LANG variables: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in %sconnect_without_oracle_home.php on line %d +bool(false) +Done diff --git a/ext/oci8/tests/create_table.inc b/ext/oci8/tests/create_table.inc index c423ce577..d6debf233 100644 --- a/ext/oci8/tests/create_table.inc +++ b/ext/oci8/tests/create_table.inc @@ -1,11 +1,18 @@ <?php - if ($connection) { + if ($c) { + $ora_sql = "DROP TABLE + ".$schema.$table_name." + "; + + $statement = OCIParse($c, $ora_sql); + @OCIExecute($statement); + $ora_sql = "CREATE TABLE - ".$schema."php_test_table (id NUMBER, value NUMBER) + ".$schema.$table_name." (id NUMBER, value NUMBER, blob BLOB, clob CLOB, string VARCHAR(10)) "; - $statement = OCIParse($connection,$ora_sql); + $statement = OCIParse($c,$ora_sql); OCIExecute($statement); } diff --git a/ext/oci8/tests/create_type.inc b/ext/oci8/tests/create_type.inc new file mode 100644 index 000000000..e23f7cb90 --- /dev/null +++ b/ext/oci8/tests/create_type.inc @@ -0,0 +1,17 @@ +<?php + + if ($c) { + $ora_sql = "DROP TYPE + ".$type_name." + "; + + $statement = OCIParse($c,$ora_sql); + @OCIExecute($statement); + + $ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER(11)"; + + $statement = OCIParse($c,$ora_sql); + OCIExecute($statement); + } + +?> diff --git a/ext/oci8/tests/cursor_bind.phpt b/ext/oci8/tests/cursor_bind.phpt new file mode 100644 index 000000000..c2ce15cb3 --- /dev/null +++ b/ext/oci8/tests/cursor_bind.phpt @@ -0,0 +1,99 @@ +--TEST-- +bind and fetch cursor from a statement +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$drop_table = "DROP TABLE ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $drop_table))) { + die("oci_parse(drop) failed!\n"); +} + +@oci_execute($s); + +$create_table = "CREATE TABLE ".$schema.$table_name." (id NUMBER, value VARCHAR(20))"; + +if (!($s = oci_parse($c, $create_table))) { + die("oci_parse(create) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(create) failed!\n"); +} + +$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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + + +$sql = " +DECLARE +TYPE curtype IS REF CURSOR; +cursor_var curtype; +BEGIN + OPEN cursor_var FOR SELECT id, value FROM ".$schema.$table_name."; + :curs := cursor_var; +END; +"; + +$stmt = oci_parse($c, $sql); + +$cursor = oci_new_cursor($c); +oci_bind_by_name($stmt, ":curs", $cursor, -1, OCI_B_CURSOR); + +oci_execute($stmt); + +oci_execute($cursor); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); + +echo "Done\n"; + +$drop_table = "DROP TABLE ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $drop_table))) { + die("oci_parse(drop) failed!\n"); +} + +@oci_execute($s); + +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +bool(false) +Done diff --git a/ext/oci8/tests/cursor_bind_err.phpt b/ext/oci8/tests/cursor_bind_err.phpt new file mode 100644 index 000000000..267c4d94f --- /dev/null +++ b/ext/oci8/tests/cursor_bind_err.phpt @@ -0,0 +1,48 @@ +--TEST-- +binding a cursor (with errors) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$sql = "select CURSOR(select * from ".$schema.$table_name.") into :cursor from dual"; +$stmt = oci_parse($c, $sql); + +$cursor = oci_new_cursor($c); +oci_bind_by_name($stmt, ":cursor", $cursor, -1, OCI_B_CURSOR); + +oci_execute($stmt); + +oci_execute($cursor); +var_dump(oci_fetch_assoc($cursor)); + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number in %s on line %d + +Warning: oci_fetch_assoc(): ORA-24338: statement handle not executed in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/cursors.phpt b/ext/oci8/tests/cursors.phpt new file mode 100644 index 000000000..6c92a2b91 --- /dev/null +++ b/ext/oci8/tests/cursors.phpt @@ -0,0 +1,59 @@ +--TEST-- +fetching cursor from a statement +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual"; +$stmt = oci_parse($c, $sql); + +oci_execute($stmt); + +while ($data = oci_fetch_assoc($stmt)) { + oci_execute($data["CURS"]); + $subdata = oci_fetch_assoc($data["CURS"]); + var_dump($subdata); + var_dump(oci_cancel($data["CURS"])); + $subdata = oci_fetch_assoc($data["CURS"]); + var_dump($subdata); + var_dump(oci_cancel($data["CURS"])); +} + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +bool(true) + +Warning: oci_fetch_assoc()%sORA-01002: fetch out of sequence in %scursors.php on line %d +bool(false) +bool(true) +Done diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt new file mode 100644 index 000000000..cf3b5f957 --- /dev/null +++ b/ext/oci8/tests/cursors_old.phpt @@ -0,0 +1,64 @@ +--TEST-- +fetching cursor from a statement +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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 = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s)) { + die("ociexecute(insert) failed!\n"); + } +} + +if (!ocicommit($c)) { + die("ocicommit() failed!\n"); +} + +$sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual"; +$stmt = ociparse($c, $sql); + +ociexecute($stmt); + +while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) { + ociexecute($data["CURS"]); + ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); + var_dump($subdata); + var_dump(ocicancel($data["CURS"])); + ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); + var_dump($subdata); + var_dump(ocicancel($data["CURS"])); +} + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +bool(true) + +Warning: ocifetchinto():%sORA-01002: fetch out of sequence in %scursors_old.php on line %d +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +bool(true) +Done diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt new file mode 100644 index 000000000..a3e393240 --- /dev/null +++ b/ext/oci8/tests/debug.phpt @@ -0,0 +1,31 @@ +--TEST-- +oci_internal_debug() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +oci_internal_debug(true); + +if (!empty($dbase)) { + oci_connect($user, $password, $dbase); +} +else { + oci_connect($user, $password); +} + +echo "Done\n"; + +?> +--EXPECTF-- +OCI8 DEBUG: OCINlsEnvironmentVariableGet in php_oci_do_connect_ex() (%s/oci8.c:%d) +Done +OCI8 DEBUG: OCISessionEnd in php_oci_connection_close() (%s/oci8.c:%d) +OCI8 DEBUG: OCIHandleFree in php_oci_connection_close() (%s/oci8.c:%d) +OCI8 DEBUG: OCIServerDetach in php_oci_connection_close() (%s/oci8.c:%d) +OCI8 DEBUG: OCIHandleFree in php_oci_connection_close() (%s/oci8.c:%d) +OCI8 DEBUG: OCIHandleFree in php_oci_connection_close() (%s/oci8.c:%d) +OCI8 DEBUG: OCIHandleFree in php_oci_connection_close() (%s/oci8.c:%d) +OCI8 DEBUG: OCIHandleFree in php_oci_connection_close() (%s/oci8.c:%d) diff --git a/ext/oci8/tests/default_prefetch.phpt b/ext/oci8/tests/default_prefetch.phpt new file mode 100644 index 000000000..cc02b6a1c --- /dev/null +++ b/ext/oci8/tests/default_prefetch.phpt @@ -0,0 +1,50 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=20 +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); + +var_dump(oci_num_rows($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/default_prefetch1.phpt b/ext/oci8/tests/default_prefetch1.phpt new file mode 100644 index 000000000..aa130e9f9 --- /dev/null +++ b/ext/oci8/tests/default_prefetch1.phpt @@ -0,0 +1,50 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=100 +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); + +var_dump(oci_num_rows($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/default_prefetch2.phpt b/ext/oci8/tests/default_prefetch2.phpt new file mode 100644 index 000000000..ac623a274 --- /dev/null +++ b/ext/oci8/tests/default_prefetch2.phpt @@ -0,0 +1,53 @@ +--TEST-- +oci8.default_prefetch ini option +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.default_prefetch=100 +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +var_dump(oci_set_prefetch($s, 10)); + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); + +var_dump(oci_num_rows($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt new file mode 100644 index 000000000..c76f360f2 --- /dev/null +++ b/ext/oci8/tests/define.phpt @@ -0,0 +1,41 @@ +--TEST-- +oci_define_by_name() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); +} + +if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); +} + +$stmt = oci_parse($c, "SELECT string FROM ".$table_name.""); + +/* the define MUST be done BEFORE ociexecute! */ + +$strong = ''; +oci_define_by_name($stmt, "STRING", $string, 20); + +oci_execute($stmt); + +while (oci_fetch($stmt)) { + var_dump($string); +} + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECT-- +string(4) "some" +Done diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt new file mode 100644 index 000000000..da52e619c --- /dev/null +++ b/ext/oci8/tests/define_old.phpt @@ -0,0 +1,41 @@ +--TEST-- +ocidefinebyname() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); +} + +if (!ociexecute($s)) { + die("oci_execute(insert) failed!\n"); +} + +$stmt = ociparse($c, "SELECT string FROM ".$table_name.""); + +/* the define MUST be done BEFORE ociexecute! */ + +$strong = ''; +ocidefinebyname($stmt, "STRING", $string, 20); + +ociexecute($stmt); + +while (ocifetch($stmt)) { + var_dump($string); +} + +require dirname(__FILE__)."/drop_table.inc"; + +echo "Done\n"; + +?> +--EXPECT-- +string(4) "some" +Done diff --git a/ext/oci8/tests/descriptors.phpt b/ext/oci8/tests/descriptors.phpt new file mode 100644 index 000000000..8be4f3a06 --- /dev/null +++ b/ext/oci8/tests/descriptors.phpt @@ -0,0 +1,49 @@ +--TEST-- +commit connection after destroying the descriptor +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +unset($blob); +unset($statement); + +oci_commit($c); + +$ora_sql = "SELECT blob FROM ".$schema.$table_name." "; +$statement = oci_parse($c,$ora_sql); +oci_execute($statement, OCI_DEFAULT); + +var_dump($row = oci_fetch_assoc($statement)); +unset($row['BLOB']); + +oci_commit($c); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECTF-- +array(1) { + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +Done diff --git a/ext/oci8/tests/drop_table.inc b/ext/oci8/tests/drop_table.inc index 4e558f5e3..ffd99f5af 100644 --- a/ext/oci8/tests/drop_table.inc +++ b/ext/oci8/tests/drop_table.inc @@ -1,11 +1,11 @@ <?php - if ($connection) { + if ($c) { $ora_sql = "DROP TABLE - ".$schema."php_test_table + ".$schema.$table_name." "; - $statement = OCIParse($connection,$ora_sql); + $statement = OCIParse($c,$ora_sql); OCIExecute($statement); } diff --git a/ext/oci8/tests/drop_type.inc b/ext/oci8/tests/drop_type.inc new file mode 100644 index 000000000..047968ef2 --- /dev/null +++ b/ext/oci8/tests/drop_type.inc @@ -0,0 +1,12 @@ +<?php + + if ($c) { + $ora_sql = "DROP TYPE + ".$type_name." + "; + + $statement = OCIParse($c,$ora_sql); + OCIExecute($statement); + } + +?> diff --git a/ext/oci8/tests/error.phpt b/ext/oci8/tests/error.phpt new file mode 100644 index 000000000..743820f90 --- /dev/null +++ b/ext/oci8/tests/error.phpt @@ -0,0 +1,40 @@ +--TEST-- +oci_error() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(oci_connect($user, $password, $dbase)); +} +else { + var_dump(oci_connect($user, $password)); +} + +var_dump($s = oci_parse($c, "WRONG SYNTAX")); +var_dump(oci_execute($s)); +var_dump(oci_error($s)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%s) of type (oci8 connection) +resource(%s) of type (oci8 statement) + +Warning: oci_execute(): ORA-00900: invalid SQL statement in %s on line %d +bool(false) +array(4) { + ["code"]=> + int(900) + ["message"]=> + string(32) "ORA-00900: invalid SQL statement" + ["offset"]=> + int(0) + ["sqltext"]=> + string(12) "WRONG SYNTAX" +} +Done diff --git a/ext/oci8/tests/error1.phpt b/ext/oci8/tests/error1.phpt new file mode 100644 index 000000000..28408f9c9 --- /dev/null +++ b/ext/oci8/tests/error1.phpt @@ -0,0 +1,18 @@ +--TEST-- +oci_error() when oci_connect() fails +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +var_dump(oci_connect("some", "some", "some")); +var_dump(oci_error()); + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in %s on line %d +bool(false) +bool(false) +Done diff --git a/ext/oci8/tests/error_old.phpt b/ext/oci8/tests/error_old.phpt new file mode 100644 index 000000000..a6889c897 --- /dev/null +++ b/ext/oci8/tests/error_old.phpt @@ -0,0 +1,40 @@ +--TEST-- +ocierror() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump(ocilogon($user, $password, $dbase)); +} +else { + var_dump(ocilogon($user, $password)); +} + +var_dump($s = ociparse($c, "WRONG SYNTAX")); +var_dump(ociexecute($s)); +var_dump(ocierror($s)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%s) of type (oci8 connection) +resource(%s) of type (oci8 statement) + +Warning: ociexecute(): ORA-00900: invalid SQL statement in %s on line %d +bool(false) +array(4) { + ["code"]=> + int(900) + ["message"]=> + string(32) "ORA-00900: invalid SQL statement" + ["offset"]=> + int(0) + ["sqltext"]=> + string(12) "WRONG SYNTAX" +} +Done diff --git a/ext/oci8/tests/exec_fetch.phpt b/ext/oci8/tests/exec_fetch.phpt new file mode 100644 index 000000000..6734f6169 --- /dev/null +++ b/ext/oci8/tests/exec_fetch.phpt @@ -0,0 +1,19 @@ +--TEST-- +fetch after failed oci_execute() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$sql = "select 2 from nonex_dual"; +$stmt = oci_parse($c, $sql); + +var_dump(oci_execute($stmt)); +var_dump(oci_fetch_array($stmt)); + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/ext/oci8/tests/execute_mode.phpt b/ext/oci8/tests/execute_mode.phpt new file mode 100644 index 000000000..90570cae8 --- /dev/null +++ b/ext/oci8/tests/execute_mode.phpt @@ -0,0 +1,19 @@ +--TEST-- +oci_execute() and invalid execute mode +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$pc = oci_pconnect($user, $password, $dbase); + +$stmt = oci_parse($pc, "select NULL from dual"); +oci_execute($stmt, -1); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_execute(): Invalid execute mode given: -1 in %s on line %d +Done diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt new file mode 100644 index 000000000..33cba657b --- /dev/null +++ b/ext/oci8/tests/fetch.phpt @@ -0,0 +1,56 @@ +--TEST-- +ocifetch() & ociresult() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +while(ocifetch($s)) { + $i = 1; + while ($row = ociresult($s, $i)) { + $i++; + var_dump($row); + } +} + +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" +Done diff --git a/ext/oci8/tests/fetch_all.phpt b/ext/oci8/tests/fetch_all.phpt new file mode 100644 index 000000000..5d3738b89 --- /dev/null +++ b/ext/oci8/tests/fetch_all.phpt @@ -0,0 +1,149 @@ +--TEST-- +oci_fetch_all() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +/* oci_fetch_all */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(oci_fetch_all($s, $all)); +var_dump($all); + +/* ocifetchstatement */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(ocifetchstatement($s, $all)); +var_dump($all); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +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(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } + ["STRING"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } +} +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(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } + ["STRING"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/fetch_array.phpt b/ext/oci8/tests/fetch_array.phpt new file mode 100644 index 000000000..bfffd4e7d --- /dev/null +++ b/ext/oci8/tests/fetch_array.phpt @@ -0,0 +1,230 @@ +--TEST-- +oci_fetch_array() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s)) { + var_dump($row); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_NUM)) { + var_dump($row); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_ASSOC)) { + var_dump($row); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_BOTH)) { + var_dump($row); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_RETURN_LOBS)) { + var_dump($row); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_array($s, OCI_RETURN_NULLS)) { + var_dump($row); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +Done diff --git a/ext/oci8/tests/fetch_assoc.phpt b/ext/oci8/tests/fetch_assoc.phpt new file mode 100644 index 000000000..2c9590db5 --- /dev/null +++ b/ext/oci8/tests/fetch_assoc.phpt @@ -0,0 +1,64 @@ +--TEST-- +oci_fetch_assoc() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_assoc($s)) { + var_dump($row); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +Done diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt new file mode 100644 index 000000000..379f5fc14 --- /dev/null +++ b/ext/oci8/tests/fetch_into.phpt @@ -0,0 +1,82 @@ +--TEST-- +ocifetchinto() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +/* oci_fetch_all */ +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s, $all)); +var_dump($all); + +/* oci_fetch_all */ +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'; + +echo "Done\n"; +?> +--EXPECT-- +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +int(5) +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +Done diff --git a/ext/oci8/tests/fetch_into1.phpt b/ext/oci8/tests/fetch_into1.phpt new file mode 100644 index 000000000..263590d14 --- /dev/null +++ b/ext/oci8/tests/fetch_into1.phpt @@ -0,0 +1,192 @@ +--TEST-- +various ocifetchinto() tests +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__).'/create_table.inc'; + +$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, string) VALUES (1, 1, NULL)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<20; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s, $all, OCI_NUM)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_ASSOC)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_RETURN_NULLS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); +var_dump($all); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +int(5) +array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +int(5) +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +int(5) +array(4) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +int(5) +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +int(5) +array(10) { + [0]=> + string(1) "1" + ["ID"]=> + string(1) "1" + [1]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + [2]=> + NULL + ["BLOB"]=> + NULL + [3]=> + NULL + ["CLOB"]=> + NULL + [4]=> + NULL + ["STRING"]=> + NULL +} +int(5) +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +int(5) +array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL +} +int(5) +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +Done diff --git a/ext/oci8/tests/fetch_into2.phpt b/ext/oci8/tests/fetch_into2.phpt new file mode 100644 index 000000000..c196d39f6 --- /dev/null +++ b/ext/oci8/tests/fetch_into2.phpt @@ -0,0 +1,70 @@ +--TEST-- +ocifetchinto() & wrong number of params +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; +require dirname(__FILE__).'/create_table.inc'; + +$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, string) VALUES (1, 1, NULL)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<20; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +var_dump(ocifetchinto($s)); +var_dump($all); +var_dump(ocifetchinto($s, $all, OCI_ASSOC, 5)); +var_dump($all); +var_dump(ocifetchinto($c, $all, OCI_RETURN_LOBS)); +var_dump($all); +var_dump(ocifetchinto($s, $all, 1000000)); +var_dump($all); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECTF-- +Warning: ocifetchinto() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Notice: Undefined variable: all in %s on line %d +NULL + +Warning: ocifetchinto() expects at most 3 parameters, 4 given in %s on line %d +NULL +NULL + +Warning: ocifetchinto(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) +NULL +int(5) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +Done diff --git a/ext/oci8/tests/fetch_object.phpt b/ext/oci8/tests/fetch_object.phpt new file mode 100644 index 000000000..d6b2714b9 --- /dev/null +++ b/ext/oci8/tests/fetch_object.phpt @@ -0,0 +1,64 @@ +--TEST-- +oci_fetch_object() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_object($s)) { + var_dump($row); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +object(stdClass)#1 (2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +object(stdClass)#2 (2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +object(stdClass)#1 (2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" +} +Done diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt new file mode 100644 index 000000000..d8a68cabb --- /dev/null +++ b/ext/oci8/tests/fetch_row.phpt @@ -0,0 +1,64 @@ +--TEST-- +oci_fetch_row() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} +while ($row = oci_fetch_row($s)) { + var_dump($row); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +Done diff --git a/ext/oci8/tests/field_funcs.phpt b/ext/oci8/tests/field_funcs.phpt new file mode 100644 index 000000000..2f1dbd710 --- /dev/null +++ b/ext/oci8/tests/field_funcs.phpt @@ -0,0 +1,105 @@ +--TEST-- +oci_field_*() family +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_array($s, OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +foreach ($row as $num => $field) { + $num++; + var_dump(oci_field_is_null($s, $num)); + var_dump(oci_field_name($s, $num)); + var_dump(oci_field_type($s, $num)); + var_dump(oci_field_type_raw($s, $num)); + var_dump(oci_field_scale($s, $num)); + var_dump(oci_field_precision($s, $num)); + var_dump(oci_field_size($s, $num)); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +string(2) "ID" +string(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(false) +string(5) "VALUE" +string(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(true) +string(4) "BLOB" +string(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +string(4) "CLOB" +string(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +string(6) "STRING" +string(7) "VARCHAR" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/field_funcs1.phpt b/ext/oci8/tests/field_funcs1.phpt new file mode 100644 index 000000000..68986e051 --- /dev/null +++ b/ext/oci8/tests/field_funcs1.phpt @@ -0,0 +1,179 @@ +--TEST-- +oci_field_*() family +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +$row = oci_fetch_array($s, OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +var_dump(oci_field_is_null($s, -1)); +var_dump(oci_field_name($s, -1)); +var_dump(oci_field_type($s, -1)); +var_dump(oci_field_type_raw($s, -1)); +var_dump(oci_field_scale($s, -1)); +var_dump(oci_field_precision($s, -1)); +var_dump(oci_field_size($s, -1)); + +var_dump(oci_field_is_null($s, "none")); +var_dump(oci_field_name($s, "none")); +var_dump(oci_field_type($s, "none")); +var_dump(oci_field_type_raw($s, "none")); +var_dump(oci_field_scale($s, "none")); +var_dump(oci_field_precision($s, "none")); +var_dump(oci_field_size($s, "none")); + +var_dump(oci_field_is_null($c, -1)); +var_dump(oci_field_name($c, -1)); +var_dump(oci_field_type($c, -1)); +var_dump(oci_field_type_raw($c, -1)); +var_dump(oci_field_scale($c, -1)); +var_dump(oci_field_precision($c, -1)); +var_dump(oci_field_size($c, -1)); + +var_dump(oci_field_is_null($s, array())); +var_dump(oci_field_name($s, array())); +var_dump(oci_field_type($s, array())); +var_dump(oci_field_type_raw($s, array())); +var_dump(oci_field_scale($s, array())); +var_dump(oci_field_precision($s, array())); +var_dump(oci_field_size($s, array())); + +var_dump(oci_field_size($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} + +Warning: oci_field_is_null(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_is_null(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_is_null(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_name(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_type(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_scale(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_precision(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_size(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_is_null(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_size() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/field_funcs_old.phpt b/ext/oci8/tests/field_funcs_old.phpt new file mode 100644 index 000000000..8627f6a78 --- /dev/null +++ b/ext/oci8/tests/field_funcs_old.phpt @@ -0,0 +1,105 @@ +--TEST-- +ocicolumn*() family +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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 = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s)) { + die("ociexecute(insert) failed!\n"); + } +} + +if (!ocicommit($c)) { + die("ocicommit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema."".$table_name.""; + +if (!($s = ociparse($c, $select_sql))) { + die("ociparse(select) failed!\n"); +} + +if (!ociexecute($s)) { + die("ociexecute(select) failed!\n"); +} + +ocifetchinto($s, $row, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); +var_dump($row); + +foreach ($row as $num => $field) { + $num++; + var_dump(ocicolumnisnull($s, $num)); + var_dump(ocicolumnname($s, $num)); + var_dump(ocicolumntype($s, $num)); + var_dump(ocicolumntyperaw($s, $num)); + var_dump(ocicolumnscale($s, $num)); + var_dump(ocicolumnprecision($s, $num)); + var_dump(ocicolumnsize($s, $num)); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +string(2) "ID" +string(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(false) +string(5) "VALUE" +string(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(true) +string(4) "BLOB" +string(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +string(4) "CLOB" +string(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +string(6) "STRING" +string(7) "VARCHAR" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/lob_001.phpt b/ext/oci8/tests/lob_001.phpt Binary files differnew file mode 100644 index 000000000..029888469 --- /dev/null +++ b/ext/oci8/tests/lob_001.phpt diff --git a/ext/oci8/tests/lob_002.phpt b/ext/oci8/tests/lob_002.phpt new file mode 100644 index 000000000..ebbef1815 --- /dev/null +++ b/ext/oci8/tests/lob_002.phpt @@ -0,0 +1,66 @@ +--TEST-- +oci_lob_write() and friends (with errors) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob); + +var_dump($blob->write("test", -1)); +var_dump($blob->write("test", "str")); +var_dump($blob->write("test", 1000000)); +var_dump($blob->write(str_repeat("test", 10000), 1000000)); +var_dump($blob->tell()); +var_dump($blob->seek("str", -5)); +var_dump($blob->flush()); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name.""; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row = oci_fetch_array($s, OCI_RETURN_LOBS); + +var_dump(strlen($row[0])); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(0) + +Warning: OCI-Lob::write() expects parameter 2 to be long, string given in %slob_002.php on line %d +NULL +int(4) +int(40000) +int(40004) + +Warning: OCI-Lob::seek() expects parameter 1 to be long, string given in %slob_002.php on line %d +NULL +bool(false) +int(40004) +Done diff --git a/ext/oci8/tests/lob_003.phpt b/ext/oci8/tests/lob_003.phpt Binary files differnew file mode 100644 index 000000000..8a492d16c --- /dev/null +++ b/ext/oci8/tests/lob_003.phpt diff --git a/ext/oci8/tests/lob_004.phpt b/ext/oci8/tests/lob_004.phpt new file mode 100644 index 000000000..32de4a012 --- /dev/null +++ b/ext/oci8/tests/lob_004.phpt @@ -0,0 +1,80 @@ +--TEST-- +oci_lob_seek()/rewind()/append() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob); + +var_dump($blob->write("test")); +var_dump($blob->rewind()); +var_dump($blob->write("str")); +var_dump($blob->seek(10, OCI_SEEK_SET)); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row = oci_fetch_array($s)); + +var_dump($row[0]->append($blob)); +var_dump($row[0]->read(10000)); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row = oci_fetch_array($s); + +var_dump($row[0]->read(10000)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(4) +bool(true) +int(3) +bool(true) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +bool(true) +string(4) "strt" +string(8) "strtstrt" +Done diff --git a/ext/oci8/tests/lob_005.phpt b/ext/oci8/tests/lob_005.phpt new file mode 100644 index 000000000..e1ac6e534 --- /dev/null +++ b/ext/oci8/tests/lob_005.phpt @@ -0,0 +1,52 @@ +--TEST-- +oci_lob_is_equal() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row = oci_fetch_array($s)); + +var_dump(oci_lob_is_equal($row[0], $row['BLOB'])); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +bool(true) +Done diff --git a/ext/oci8/tests/lob_006.phpt b/ext/oci8/tests/lob_006.phpt Binary files differnew file mode 100644 index 000000000..3192ebc90 --- /dev/null +++ b/ext/oci8/tests/lob_006.phpt diff --git a/ext/oci8/tests/lob_007.phpt b/ext/oci8/tests/lob_007.phpt new file mode 100644 index 000000000..1fe63092c --- /dev/null +++ b/ext/oci8/tests/lob_007.phpt @@ -0,0 +1,66 @@ +--TEST-- +oci_lob_write()/size()/load() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob); + +var_dump($blob->size()); +var_dump($blob->write(str_repeat("string.", 1000))); +var_dump($blob->size()); +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row = oci_fetch_array($s)); + +var_dump($row[0]->size()); +var_dump(strlen($row[0]->load())); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(0) +int(7000) +int(7000) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +int(7000) +int(7000) +Done diff --git a/ext/oci8/tests/lob_008.phpt b/ext/oci8/tests/lob_008.phpt new file mode 100644 index 000000000..a36bb4a34 --- /dev/null +++ b/ext/oci8/tests/lob_008.phpt @@ -0,0 +1,65 @@ +--TEST-- +oci_lob_write()/read()/eof() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob); + +var_dump($blob->write(str_repeat("string.", 1000))); +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row = oci_fetch_array($s)); + + +$len = 0; +while (!$row[0]->eof()) { + $len += strlen($row[0]->read(1024)); +} +var_dump($len); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(7000) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +int(7000) +Done diff --git a/ext/oci8/tests/lob_009.phpt b/ext/oci8/tests/lob_009.phpt new file mode 100644 index 000000000..b9f740112 --- /dev/null +++ b/ext/oci8/tests/lob_009.phpt @@ -0,0 +1,69 @@ +--TEST-- +oci_lob_import()/read() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob); +var_dump($blob->seek(10, OCI_SEEK_CUR)); +var_dump($blob->import(dirname(__FILE__)."/lob_009.txt")); +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row = oci_fetch_array($s)); + +while (!$row[0]->eof()) { + var_dump($row[0]->read(1024)); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +bool(true) +bool(true) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["BLOB"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(43) "this +is +a +test +file for +test lob_009.phpt +" +Done diff --git a/ext/oci8/tests/lob_009.txt b/ext/oci8/tests/lob_009.txt new file mode 100644 index 000000000..f57bc8af3 --- /dev/null +++ b/ext/oci8/tests/lob_009.txt @@ -0,0 +1,6 @@ +this +is +a +test +file for +test lob_009.phpt diff --git a/ext/oci8/tests/lob_010.phpt b/ext/oci8/tests/lob_010.phpt new file mode 100644 index 000000000..59f3e145f --- /dev/null +++ b/ext/oci8/tests/lob_010.phpt @@ -0,0 +1,46 @@ +--TEST-- +oci_lob_save() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob->save("string")); +var_dump($blob->save("string", 3)); +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row = oci_fetch_array($s); + +while (!$row[0]->eof()) { + var_dump($row[0]->read(1024)); +} + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +bool(true) +bool(true) +string(9) "strstring" +Done diff --git a/ext/oci8/tests/lob_011.phpt b/ext/oci8/tests/lob_011.phpt new file mode 100644 index 000000000..2dd78985f --- /dev/null +++ b/ext/oci8/tests/lob_011.phpt @@ -0,0 +1,76 @@ +--TEST-- +oci_lob_copy() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (id, blob) + VALUES (1, empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob->write("some string here. string, I said")); +oci_commit($c); + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (id, blob) + VALUES (2, empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1"; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row1 = oci_fetch_array($s); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row2 = oci_fetch_array($s); + +var_dump(oci_lob_copy($row2[0], $row1[0])); +var_dump($row1[0]->read(100)); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(32) +bool(true) +string(32) "some string here. string, I said" +array(1) { + [0]=> + string(32) "some string here. string, I said" +} +Done diff --git a/ext/oci8/tests/lob_012.phpt b/ext/oci8/tests/lob_012.phpt new file mode 100644 index 000000000..2061969bc --- /dev/null +++ b/ext/oci8/tests/lob_012.phpt @@ -0,0 +1,50 @@ +--TEST-- +oci_lob_export() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +$blob; + +var_dump($blob->write("test string is here\nnew string")); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row = oci_fetch_array($s); + +var_dump($row[0]->export(dirname(__FILE__)."/lob_012.tmp", 3, 10)); + +var_dump(file_get_contents(dirname(__FILE__)."/lob_012.tmp")); + +@unlink(dirname(__FILE__)."/lob_012.tmp"); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(30) +bool(true) +string(10) "t string i" +Done diff --git a/ext/oci8/tests/lob_013.phpt b/ext/oci8/tests/lob_013.phpt new file mode 100644 index 000000000..c56de5619 --- /dev/null +++ b/ext/oci8/tests/lob_013.phpt @@ -0,0 +1,54 @@ +--TEST-- +lob buffering +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob->write("test")); +var_dump($blob->getBuffering()); +var_dump($blob->setBuffering(true)); +var_dump($blob->write("test")); +var_dump($blob->getBuffering()); +var_dump($blob->flush()); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name.""; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row = oci_fetch_array($s, OCI_RETURN_LOBS); + +var_dump($row[0]); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(4) +bool(false) +bool(true) +int(4) +bool(true) +bool(true) +string(8) "testtest" +Done diff --git a/ext/oci8/tests/lob_014.phpt b/ext/oci8/tests/lob_014.phpt new file mode 100644 index 000000000..60ed94531 --- /dev/null +++ b/ext/oci8/tests/lob_014.phpt @@ -0,0 +1,58 @@ +--TEST-- +oci_lob_free()/close() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +$blob; + +var_dump($blob->write("test")); +var_dump($blob->close()); +var_dump($blob->write("test")); +var_dump($blob->free()); +var_dump($blob->write("test")); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name.""; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +var_dump(oci_fetch_array($s, OCI_NUM + OCI_RETURN_LOBS)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +int(4) + +Warning: OCI-Lob::close(): ORA-22289: cannot perform operation on an unopened file or LOB in %slob_014.php on line %d +bool(false) +int(4) +bool(true) + +Warning: OCI-Lob::write(): %d is not a valid oci8 descriptor resource in %slob_014.php on line %d +bool(false) +array(1) { + [0]=> + string(8) "testtest" +} +Done diff --git a/ext/oci8/tests/lob_015.phpt b/ext/oci8/tests/lob_015.phpt new file mode 100644 index 000000000..d2b7f0ad4 --- /dev/null +++ b/ext/oci8/tests/lob_015.phpt @@ -0,0 +1,51 @@ +--TEST-- +various tests with wrong param count +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB,1,2,3); +$blob = oci_new_descriptor($c); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB,4); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB,4,5); +oci_bind_by_name($statement,":v_blob", $blob,-1); +oci_bind_by_name($statement,":v_blob", $blob); +oci_bind_by_name($statement,":v_blob"); +oci_bind_by_name($statement); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: oci_new_descriptor() expects at most 2 parameters, 5 given in %slob_015.php on line %d + +Warning: oci_bind_by_name() expects at most 5 parameters, 6 given in %slob_015.php on line %d + +Warning: oci_bind_by_name() expects at most 5 parameters, 7 given in %slob_015.php on line %d + +Notice: Object of class OCI-Lob to string conversion in %slob_015.php on line %d + +Warning: oci_bind_by_name() expects at least 3 parameters, 2 given in %slob_015.php on line %d + +Warning: oci_bind_by_name() expects at least 3 parameters, 1 given in %slob_015.php on line %d + +Warning: oci_execute(): ORA-00932: inconsistent datatypes: expected NUMBER got BLOB in %slob_015.php on line %d +string(6) "Object" +Done diff --git a/ext/oci8/tests/lob_016.phpt b/ext/oci8/tests/lob_016.phpt new file mode 100644 index 000000000..642e7195e --- /dev/null +++ b/ext/oci8/tests/lob_016.phpt @@ -0,0 +1,67 @@ +--TEST-- +returning multiple lobs +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table lob_test(lob_1 BLOB, lob_2 BLOB)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$init = "INSERT INTO lob_test VALUES(EMPTY_BLOB(), EMPTY_BLOB())"; +$statement = oci_parse($c, $init); +oci_execute($statement); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +$row['LOB_1']->write("first"); +$row['LOB_2']->write("second"); + +unset($row); + +oci_commit($c); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +var_dump($row); +var_dump($row['LOB_1']->load()); +var_dump($row['LOB_2']->load()); + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + ["LOB_1"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["LOB_2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(5) "first" +string(6) "second" +Done diff --git a/ext/oci8/tests/lob_017.phpt b/ext/oci8/tests/lob_017.phpt new file mode 100644 index 000000000..ed12cc468 --- /dev/null +++ b/ext/oci8/tests/lob_017.phpt @@ -0,0 +1,69 @@ +--TEST-- +returning multiple lobs (using persistent connection) +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$c = oci_pconnect($user, $password, $dbase); + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table lob_test(lob_1 BLOB, lob_2 BLOB)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$init = "INSERT INTO lob_test VALUES(EMPTY_BLOB(), EMPTY_BLOB())"; +$statement = oci_parse($c, $init); +oci_execute($statement); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +$row['LOB_1']->write("first"); +$row['LOB_2']->write("second"); + +unset($row); + +oci_commit($c); + +$select = "SELECT * FROM lob_test FOR UPDATE"; +$statement = oci_parse($c, $select); +oci_execute($statement, OCI_DEFAULT); + +$row = oci_fetch_assoc($statement); + +var_dump($row); +var_dump($row['LOB_1']->load()); +var_dump($row['LOB_2']->load()); + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +array(2) { + ["LOB_1"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + ["LOB_2"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(5) "first" +string(6) "second" +Done diff --git a/ext/oci8/tests/lob_018.phpt b/ext/oci8/tests/lob_018.phpt new file mode 100644 index 000000000..35cec4bd7 --- /dev/null +++ b/ext/oci8/tests/lob_018.phpt @@ -0,0 +1,67 @@ +--TEST-- +fetching the same lob several times +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +$create = "CREATE table lob_test(mykey NUMBER, lob_1 CLOB)"; +$statement = oci_parse($c, $create); +oci_execute($statement); + +$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(1, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob"; +$statement = oci_parse($c, $init); +$clob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB); +oci_execute($statement, OCI_DEFAULT); +$clob->save("data"); + +oci_commit($c); + +$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(2, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob"; +$statement = oci_parse($c, $init); +$clob = oci_new_descriptor($c, OCI_D_LOB); +oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB); +oci_execute($statement, OCI_DEFAULT); +$clob->save("long data"); + +oci_commit($c); + + +$query = 'SELECT * FROM lob_test ORDER BY mykey ASC'; +$statement = oci_parse ($c, $query); +oci_execute($statement, OCI_DEFAULT); + +while ($row = oci_fetch_array($statement, OCI_ASSOC)) { + $result = $row['LOB_1']->load(); + var_dump($result); +} + +$query = 'SELECT * FROM lob_test ORDER BY mykey DESC'; +$statement = oci_parse ($c, $query); +oci_execute($statement, OCI_DEFAULT); + +while ($row = oci_fetch_array($statement, OCI_ASSOC)) { + $result = $row['LOB_1']->load(); + var_dump($result); +} + +$drop = "DROP table lob_test"; +$statement = oci_parse($c, $drop); +@oci_execute($statement); + +echo "Done\n"; + +?> +--EXPECTF-- +string(4) "data" +string(9) "long data" +string(9) "long data" +string(4) "data" +Done diff --git a/ext/oci8/tests/lob_temp.phpt b/ext/oci8/tests/lob_temp.phpt new file mode 100644 index 000000000..cad2d3905 --- /dev/null +++ b/ext/oci8/tests/lob_temp.phpt @@ -0,0 +1,36 @@ +--TEST-- +temporary lobs +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->seek(0, SEEK_SET)); +var_dump($blob->read(2)); + +$c = oci_pconnect($user, $password, $dbase); + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->seek(0, SEEK_SET)); +var_dump($blob->read(2)); + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +string(4) "test" +bool(true) +string(2) "te" +bool(true) +string(4) "test" +bool(true) +string(2) "te" +Done diff --git a/ext/oci8/tests/lob_temp1.phpt b/ext/oci8/tests/lob_temp1.phpt new file mode 100644 index 000000000..2482d65f6 --- /dev/null +++ b/ext/oci8/tests/lob_temp1.phpt @@ -0,0 +1,32 @@ +--TEST-- +closing temporary lobs +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->close()); + +$c = oci_pconnect($user, $password, $dbase); + +$blob = oci_new_descriptor($c,OCI_D_LOB); +var_dump($blob->writeTemporary("test")); +var_dump($blob->load()); +var_dump($blob->close()); + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +string(4) "test" +bool(true) +bool(true) +string(4) "test" +bool(true) +Done diff --git a/ext/oci8/tests/num.phpt b/ext/oci8/tests/num.phpt new file mode 100644 index 000000000..3c333b4e3 --- /dev/null +++ b/ext/oci8/tests/num.phpt @@ -0,0 +1,66 @@ +--TEST-- +oci_num_*() family +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(ocirowcount($s)); +var_dump(oci_num_rows($s)); +var_dump(ocinumcols($s)); +var_dump(oci_num_fields($s)); + +$delete_sql = "DELETE FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $delete_sql))) { + die("oci_parse(delete) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(delete) failed!\n"); +} +oci_commit($c); + +var_dump(oci_num_rows($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(0) +int(0) +int(5) +int(5) +int(3) +Done diff --git a/ext/oci8/tests/oci_execute_segfault.phpt b/ext/oci8/tests/oci_execute_segfault.phpt new file mode 100644 index 000000000..3859f4ffe --- /dev/null +++ b/ext/oci8/tests/oci_execute_segfault.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_execute() segfault after repeated bind +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__).'/connect.inc'; +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$table_name." (blob, clob) + VALUES (empty_blob(), empty_clob()) + RETURNING + blob + INTO :v_blob "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($s); + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($s); + +echo "Done\n"; + +?> +--EXPECT-- +Done diff --git a/ext/oci8/tests/old_oci_close.phpt b/ext/oci8/tests/old_oci_close.phpt new file mode 100644 index 000000000..f15b7febe --- /dev/null +++ b/ext/oci8/tests/old_oci_close.phpt @@ -0,0 +1,23 @@ +--TEST-- +oci8.old_oci_close_semantics On +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=1 +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +var_dump($c); +var_dump(oci_close($c)); +var_dump(oci_parse($c, "select 1 from dual")); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +NULL +resource(%d) of type (oci8 statement) +Done diff --git a/ext/oci8/tests/old_oci_close1.phpt b/ext/oci8/tests/old_oci_close1.phpt new file mode 100644 index 000000000..9af2eeb39 --- /dev/null +++ b/ext/oci8/tests/old_oci_close1.phpt @@ -0,0 +1,25 @@ +--TEST-- +oci8.old_oci_close_semantics Off +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.old_oci_close_semantics=0 +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +var_dump($c); +var_dump(oci_close($c)); +var_dump(oci_parse($c, "select 1 from dual")); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +bool(true) + +Warning: oci_parse() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt new file mode 100644 index 000000000..a31843cfd --- /dev/null +++ b/ext/oci8/tests/password.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_password_change() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$new_password = "test"; +var_dump(oci_password_change($dbase, $user, $password, $new_password)); + +if (!empty($dbase)) { + var_dump($new_c = ocilogon($user,$new_password,$dbase)); +} +else { + var_dump($new_c = ocilogon($user,$new_password)); +} + +var_dump(oci_password_change($dbase, $user, $new_password, $password)); + + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt new file mode 100644 index 000000000..a31843cfd --- /dev/null +++ b/ext/oci8/tests/password_new.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_password_change() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$new_password = "test"; +var_dump(oci_password_change($dbase, $user, $password, $new_password)); + +if (!empty($dbase)) { + var_dump($new_c = ocilogon($user,$new_password,$dbase)); +} +else { + var_dump($new_c = ocilogon($user,$new_password)); +} + +var_dump(oci_password_change($dbase, $user, $new_password, $password)); + + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt new file mode 100644 index 000000000..d293fce87 --- /dev/null +++ b/ext/oci8/tests/password_old.phpt @@ -0,0 +1,30 @@ +--TEST-- +ocipasswordchange() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$new_password = "test"; +var_dump(ocipasswordchange($c, $user, $password, $new_password)); + +if (!empty($dbase)) { + var_dump($new_c = ocilogon($user,$new_password,$dbase)); +} +else { + var_dump($new_c = ocilogon($user,$new_password)); +} + +var_dump(ocipasswordchange($new_c, $user, $new_password, $password)); + + +echo "Done\n"; + +?> +--EXPECTF-- +bool(true) +resource(%d) of type (oci8 connection) +bool(true) +Done diff --git a/ext/oci8/tests/persistent.phpt b/ext/oci8/tests/persistent.phpt new file mode 100644 index 000000000..884cd35a4 --- /dev/null +++ b/ext/oci8/tests/persistent.phpt @@ -0,0 +1,26 @@ +--TEST-- +reusing persistent connections +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +var_dump(oci_pconnect($user, $password, $dbase)); +var_dump(oci_pconnect($user, $password, $dbase)); +var_dump(oci_pconnect($user, $password, $dbase)); +var_dump(oci_connect($user, $password, $dbase)); +var_dump(oci_connect($user, $password, $dbase)); +var_dump(oci_connect($user, $password, $dbase)); + +echo "Done\n"; +?> +--EXPECTF-- +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 persistent connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +resource(%d) of type (oci8 connection) +Done diff --git a/ext/oci8/tests/prefetch.phpt b/ext/oci8/tests/prefetch.phpt new file mode 100644 index 000000000..fa4b8fdc6 --- /dev/null +++ b/ext/oci8/tests/prefetch.phpt @@ -0,0 +1,51 @@ +--TEST-- +oci_set_prefetch() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $select_sql))) { + die("oci_parse(select) failed!\n"); +} + +var_dump(oci_set_prefetch($s, 10)); + +if (!oci_execute($s)) { + die("oci_execute(select) failed!\n"); +} + +var_dump(oci_fetch($s)); + +var_dump(oci_num_rows($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/prefetch_old.phpt b/ext/oci8/tests/prefetch_old.phpt new file mode 100644 index 000000000..cb9cb390e --- /dev/null +++ b/ext/oci8/tests/prefetch_old.phpt @@ -0,0 +1,51 @@ +--TEST-- +ocisetprefetch() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--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 = ociparse($c, $insert_sql))) { + die("ociparse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!ociexecute($s)) { + die("ociexecute(insert) failed!\n"); + } +} + +if (!ocicommit($c)) { + die("ocicommit() failed!\n"); +} + +$select_sql = "SELECT * FROM ".$schema.$table_name.""; + +if (!($s = ociparse($c, $select_sql))) { + die("ociparse(select) failed!\n"); +} + +var_dump(ocisetprefetch($s, 10)); + +if (!ociexecute($s)) { + die("ociexecute(select) failed!\n"); +} + +var_dump(ocifetch($s)); + +var_dump(ocirowcount($s)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +int(1) +Done diff --git a/ext/oci8/tests/privileged_connect.phpt b/ext/oci8/tests/privileged_connect.phpt new file mode 100644 index 000000000..39122240a --- /dev/null +++ b/ext/oci8/tests/privileged_connect.phpt @@ -0,0 +1,25 @@ +--TEST-- +privileged connect tests +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +oci_connect("", "", "", false, OCI_SYSOPER); +oci_connect("", "", "", false, OCI_SYSDBA); +oci_connect("", "", "", false, -1); +oci_connect("", "", "", false, "qwe"); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_connect(): Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA in %s on line %d + +Warning: oci_connect(): Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA in %s on line %d + +Warning: oci_connect(): Invalid session mode specified (-1) in %s on line %d + +Warning: oci_connect() expects parameter 5 to be long, string given in %s on line %d +Done diff --git a/ext/oci8/tests/privileged_connect1.phpt b/ext/oci8/tests/privileged_connect1.phpt new file mode 100644 index 000000000..a05a21093 --- /dev/null +++ b/ext/oci8/tests/privileged_connect1.phpt @@ -0,0 +1,27 @@ +--TEST-- +privileged connect tests +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--INI-- +oci8.privileged_connect=1 +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +oci_connect("", "", "", false, OCI_SYSOPER); +oci_connect("", "", "", false, OCI_SYSDBA); +oci_connect("", "", "", false, -1); +oci_connect("", "", "", false, "qwe"); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d + +Warning: oci_connect(): ORA-01031: insufficient privileges in %s on line %d + +Warning: oci_connect(): Invalid session mode specified (-1) in %s on line %d + +Warning: oci_connect() expects parameter 5 to be long, string given in %s on line %d +Done diff --git a/ext/oci8/tests/select_null.phpt b/ext/oci8/tests/select_null.phpt new file mode 100644 index 000000000..20307b3e2 --- /dev/null +++ b/ext/oci8/tests/select_null.phpt @@ -0,0 +1,23 @@ +--TEST-- +SELECTing NULL values +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$pc = oci_pconnect($user, $password, $dbase); + +$stmt = oci_parse($pc, "select NULL from dual"); +oci_execute($stmt); +var_dump(oci_fetch_array($stmt, OCI_RETURN_NULLS)); + +echo "Done\n"; +?> +--EXPECT-- +array(1) { + [0]=> + NULL +} +Done diff --git a/ext/oci8/tests/serverversion.phpt b/ext/oci8/tests/serverversion.phpt new file mode 100644 index 000000000..bf32fe4b5 --- /dev/null +++ b/ext/oci8/tests/serverversion.phpt @@ -0,0 +1,30 @@ +--TEST-- +oci_server_version() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c = oci_connect($user, $password, $dbase)); +} +else { + var_dump($c = oci_connect($user, $password)); +} + +$v = oci_server_version($c); +var_dump(str_replace("\n", "", $v)); + +$v = ociserverversion($c); +var_dump(str_replace("\n", "", $v)); + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +string(%d) "%s" +string(%d) "%s" +Done diff --git a/ext/oci8/tests/statement_cache.phpt b/ext/oci8/tests/statement_cache.phpt new file mode 100644 index 000000000..e7c8911e8 --- /dev/null +++ b/ext/oci8/tests/statement_cache.phpt @@ -0,0 +1,35 @@ +--TEST-- +statement cache +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$pc = oci_pconnect($user, $password, $dbase); + +$stmt = oci_parse($pc, "select 1+3 from dual", true); +oci_execute($stmt); +var_dump(oci_fetch_array($stmt)); + +$stmt = oci_parse($pc, "select 1+3 from dual", true); +oci_execute($stmt); +var_dump(oci_fetch_array($stmt)); + +echo "Done\n"; +?> +--EXPECTF-- +array(2) { + [0]=> + string(1) "4" + ["1+3"]=> + string(1) "4" +} +array(2) { + [0]=> + string(1) "4" + ["1+3"]=> + string(1) "4" +} +Done diff --git a/ext/oci8/tests/statement_type.phpt b/ext/oci8/tests/statement_type.phpt new file mode 100644 index 000000000..45221a6c7 --- /dev/null +++ b/ext/oci8/tests/statement_type.phpt @@ -0,0 +1,46 @@ +--TEST-- +oci_statement_type() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c = oci_connect($user, $password, $dbase)); +} +else { + var_dump($c = oci_connect($user, $password)); +} + +$sqls = Array( + "SELECT * FROM table", + "DELETE FROM table WHERE id = 1", + "INSERT INTO table VALUES(1)", + "UPDATE table SET id = 1", + "DROP TABLE table", + "CREATE TABLE table (id NUMBER)", + "WRONG SYNTAX", + "" +); + +foreach ($sqls as $sql) { + $s = oci_parse($c, $sql); + var_dump(oci_statement_type($s)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +string(6) "SELECT" +string(6) "DELETE" +string(6) "INSERT" +string(6) "UPDATE" +string(4) "DROP" +string(6) "CREATE" +string(7) "UNKNOWN" +string(7) "UNKNOWN" +Done diff --git a/ext/oci8/tests/statement_type_old.phpt b/ext/oci8/tests/statement_type_old.phpt new file mode 100644 index 000000000..13da41bf7 --- /dev/null +++ b/ext/oci8/tests/statement_type_old.phpt @@ -0,0 +1,46 @@ +--TEST-- +ocistatementtype() +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +if (!empty($dbase)) { + var_dump($c = ocilogon($user, $password, $dbase)); +} +else { + var_dump($c = ocilogon($user, $password)); +} + +$sqls = Array( + "SELECT * FROM table", + "DELETE FROM table WHERE id = 1", + "INSERT INTO table VALUES(1)", + "UPDATE table SET id = 1", + "DROP TABLE table", + "CREATE TABLE table (id NUMBER)", + "WRONG SYNTAX", + "" +); + +foreach ($sqls as $sql) { + $s = ociparse($c, $sql); + var_dump(ocistatementtype($s)); +} + +echo "Done\n"; + +?> +--EXPECTF-- +resource(%d) of type (oci8 connection) +string(6) "SELECT" +string(6) "DELETE" +string(6) "INSERT" +string(6) "UPDATE" +string(4) "DROP" +string(6) "CREATE" +string(7) "UNKNOWN" +string(7) "UNKNOWN" +Done diff --git a/ext/oci8/tests/uncommitted.phpt b/ext/oci8/tests/uncommitted.phpt new file mode 100644 index 000000000..3c341c8cb --- /dev/null +++ b/ext/oci8/tests/uncommitted.phpt @@ -0,0 +1,16 @@ +--TEST-- +uncommitted connection +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?> +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$stmt = oci_parse($c, "select 1 from dual"); +oci_execute($stmt, OCI_DEFAULT); + +echo "Done\n"; +?> +--EXPECTF-- +Done |
