summaryrefslogtreecommitdiff
path: root/tests/bind_char_2.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bind_char_2.phpt')
-rw-r--r--tests/bind_char_2.phpt127
1 files changed, 127 insertions, 0 deletions
diff --git a/tests/bind_char_2.phpt b/tests/bind_char_2.phpt
new file mode 100644
index 0000000000..6c7dbafcc5
--- /dev/null
+++ b/tests/bind_char_2.phpt
@@ -0,0 +1,127 @@
+--TEST--
+SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
+if ($sv !== 1) {
+ die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+}
+?>
+--FILE--
+<?php
+
+// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
+// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Initialization
+
+$stmtarray = array(
+ "alter session set nls_date_format='YYYY-MM-DD'",
+ "drop table bind_char_tab",
+ "create table bind_char_tab (id number, c1 date)",
+ "insert into bind_char_tab values (1, '2008-04-20')",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+}
+
+// Run Test
+
+$bv1 = '2008-04-20';
+
+echo "Test 1.1: Type: default. Length: default\n";
+$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv");
+$r = oci_bind_by_name($s, ":bv", $bv1);
+if ($r)
+ do_e_q($s);
+
+echo "Test 1.2: Type: AFC. Length: default\n";
+$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
+if ($r)
+ do_e_q($s);
+
+echo "Test 1.3: Type: AFC: Length: 0\n";
+$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
+if ($r)
+ do_e_q($s);
+
+echo "Test 1.4: Type: AFC: Length: strlen\n";
+$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
+if ($r)
+ do_e_q($s);
+
+echo "Test 1.5: Type: AFC. Length: strlen-1\n";
+$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
+if ($r)
+ do_e_q($s);
+
+echo "Test 1.6: Type: AFC. Length: strlen+1\n";
+$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
+if ($r)
+ do_e_q($s);
+
+
+function do_e_q($s)
+{
+ echo " Querying:\n";
+
+ $r = @oci_execute($s);
+ if (!$r) {
+ $m = oci_error($s);
+ echo " Oci_execute error ORA-".$m['code']." Exiting Query\n";
+ return;
+ }
+ while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) {
+ foreach ($row as $item) {
+ echo " :" . $item . ":\n";
+ }
+ }
+}
+
+// Cleanup
+$stmtarray = array(
+ "drop table bind_char_tab"
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ oci_execute($s);
+}
+
+oci_close($c);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+Test 1.1: Type: default. Length: default
+ Querying:
+ :1:
+ :2008-04-20:
+Test 1.2: Type: AFC. Length: default
+ Querying:
+ :1:
+ :2008-04-20:
+Test 1.3: Type: AFC: Length: 0
+ Querying:
+ Oci_execute error ORA-1460 Exiting Query
+Test 1.4: Type: AFC: Length: strlen
+ Querying:
+ :1:
+ :2008-04-20:
+Test 1.5: Type: AFC. Length: strlen-1
+ Querying:
+ :1:
+ :2008-04-20:
+Test 1.6: Type: AFC. Length: strlen+1
+ Querying:
+ :1:
+ :2008-04-20:
+Done