xref: /PHP-8.3/ext/oci8/tests/bind_empty.phpt (revision a53e5617)
1--TEST--
2binding empty values
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14$drop = "DROP table bind_empty_tab";
15$statement = oci_parse($c, $drop);
16@oci_execute($statement);
17
18$create = "CREATE table bind_empty_tab(name VARCHAR(10))";
19$statement = oci_parse($c, $create);
20oci_execute($statement);
21
22
23echo "Test 1\n";
24
25$name = null;
26$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
27oci_bind_by_name($stmt, ":name", $name);
28
29var_dump(oci_execute($stmt));
30
31echo "Test 2\n";
32
33$name = "";
34$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
35oci_bind_by_name($stmt, ":name", $name);
36
37var_dump(oci_execute($stmt));
38
39echo "Test 3\n";
40
41$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
42$res = oci_execute($stmt);
43
44$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
45$res = oci_execute($stmt);
46
47$name = null;
48$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
49oci_bind_by_name($stmt, ":name", $name);
50
51var_dump(oci_execute($stmt));
52
53$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
54oci_execute($stid);
55oci_fetch_all($stid, $res);
56var_dump($res);
57
58echo "Test 4\n";
59
60$name = "";
61$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
62oci_bind_by_name($stmt, ":name", $name);
63
64var_dump(oci_execute($stmt));
65
66$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
67oci_execute($stid);
68oci_fetch_all($stid, $res);
69var_dump($res);
70
71echo "Test 5\n";
72
73$av = $bv = 'old';
74$s = oci_parse($c, "begin :bv := null; end; ");
75oci_bind_by_name($s, ":bv", $bv);
76oci_execute($s);
77var_dump($av);
78var_dump($bv);
79
80echo "Test 6\n";
81
82$av = $bv = null;
83$s = oci_parse($c, "begin :bv := null; end; ");
84oci_bind_by_name($s, ":bv", $bv);
85oci_execute($s);
86var_dump($av);
87var_dump($bv);
88
89// Clean up
90
91$drop = "DROP table bind_empty_tab";
92$statement = oci_parse($c, $drop);
93@oci_execute($statement);
94
95?>
96--EXPECT--
97Test 1
98bool(true)
99Test 2
100bool(true)
101Test 3
102bool(true)
103array(1) {
104  ["NAME"]=>
105  array(2) {
106    [0]=>
107    string(3) "def"
108    [1]=>
109    NULL
110  }
111}
112Test 4
113bool(true)
114array(1) {
115  ["NAME"]=>
116  array(2) {
117    [0]=>
118    NULL
119    [1]=>
120    NULL
121  }
122}
123Test 5
124string(3) "old"
125NULL
126Test 6
127NULL
128NULL
129