xref: /PHP-5.3/ext/oci8/tests/error_parse.phpt (revision c7a8bd6a)
1--TEST--
2Test error handling when persistent connection is passed to oci_error()
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8// As part of the fix for Bug 42134, an error handling difference was
9// noticed when oci_error() was passed a persistent connection.  This
10// was fixed and the behavior of oci_error() for all connections types
11// was made consistent.
12
13require(dirname(__FILE__).'/details.inc');
14
15// Test parse error for normal connection
16
17if (!empty($dbase)) {
18	$c1 = oci_connect($user,$password,$dbase);
19}
20else {
21	$c1 = oci_connect($user,$password);
22}
23
24$s = @oci_parse($c1, "select ' from dual");
25if (!$s) {
26	echo "Normal connection: Parse error\n";
27	$m = oci_error($c1);
28	var_dump($m);
29}
30
31// Test parse error for new connection
32
33if (!empty($dbase)) {
34	$c2 = oci_new_connect($user,$password,$dbase);
35}
36else {
37	$c2 = oci_new_connect($user,$password);
38}
39
40$s = @oci_parse($c2, "select ' from dual");
41if (!$s) {
42	echo "New connection: Parse error\n";
43	$m = oci_error($c2);
44	var_dump($m);
45}
46
47// Test parse error for persistent connection
48
49if (!empty($dbase)) {
50	$c3 = oci_pconnect($user,$password,$dbase);
51}
52else {
53	$c3 = oci_pconnect($user,$password);
54}
55
56$s = @oci_parse($c3, "select ' from dual");
57if (!$s) {
58	echo "Persistent connection: Parse error\n";
59	$m = oci_error($c3);
60	var_dump($m);
61}
62
63// Verify that passing no connection doesn't affect future calls
64
65$m = oci_error();
66echo "No connection: error: ";
67var_dump($m);
68
69// Check the errors are still accessible in the respective handles
70
71$m = oci_error($c1);
72echo "Normal connection (take #2): Parse error: ";
73echo $m["message"], "\n";
74
75$m = oci_error($c2);
76echo "New connection (take #2): Parse error: ";
77echo $m["message"], "\n";
78
79$m = oci_error($c3);
80echo "Persistent connection (take #2): Parse error: ";
81echo $m["message"], "\n";
82
83// Now create a new error for a normal connection and check all again
84
85$s = @oci_new_collection($c1, "ABC");
86$m = oci_error($c1);
87echo "Normal connection: New Collection error: ";
88echo $m["message"], "\n";
89
90$m = oci_error($c2);
91echo "New connection (take #3): Parse error: ";
92echo $m["message"], "\n";
93
94$m = oci_error($c3);
95echo "Persistent connection (take #3): Parse error: ";
96echo $m["message"], "\n";
97
98echo "Done\n";
99
100?>
101--EXPECTF--
102Normal connection: Parse error
103array(4) {
104  ["code"]=>
105  int(1756)
106  ["message"]=>
107  string(48) "ORA-01756: %s"
108  ["offset"]=>
109  int(0)
110  ["sqltext"]=>
111  string(0) ""
112}
113New connection: Parse error
114array(4) {
115  ["code"]=>
116  int(1756)
117  ["message"]=>
118  string(48) "ORA-01756: %s"
119  ["offset"]=>
120  int(0)
121  ["sqltext"]=>
122  string(0) ""
123}
124Persistent connection: Parse error
125array(4) {
126  ["code"]=>
127  int(1756)
128  ["message"]=>
129  string(48) "ORA-01756: %s"
130  ["offset"]=>
131  int(0)
132  ["sqltext"]=>
133  string(0) ""
134}
135No connection: error: bool(false)
136Normal connection (take #2): Parse error: ORA-01756: %s
137New connection (take #2): Parse error: ORA-01756: %s
138Persistent connection (take #2): Parse error: ORA-01756: %s
139Normal connection: New Collection error: OCI-22303: type ""."ABC" not found
140New connection (take #3): Parse error: ORA-01756: %s
141Persistent connection (take #3): Parse error: ORA-01756: %s
142Done
143