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