xref: /PHP-5.4/ext/oci8/tests/bind_empty.phpt (revision c033a81b)
1--TEST--
2binding empty values
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8require dirname(__FILE__).'/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===DONE===
93<?php exit(0); ?>
94--EXPECTF--
95Test 1
96bool(true)
97Test 2
98bool(true)
99Test 3
100bool(true)
101array(1) {
102  ["NAME"]=>
103  array(2) {
104    [0]=>
105    string(3) "def"
106    [1]=>
107    NULL
108  }
109}
110Test 4
111bool(true)
112array(1) {
113  ["NAME"]=>
114  array(2) {
115    [0]=>
116    NULL
117    [1]=>
118    NULL
119  }
120}
121Test 5
122string(3) "old"
123NULL
124Test 6
125NULL
126NULL
127===DONE===
128