summaryrefslogtreecommitdiff
path: root/ext/oci8/tests/bind_empty.phpt
blob: 90e7679371def30968b70e8dcaaf78ff0101524b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--TEST--
binding empty values
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php

require dirname(__FILE__).'/connect.inc';

$drop = "DROP table bind_empty_tab";
$statement = oci_parse($c, $drop);
@oci_execute($statement);

$create = "CREATE table bind_empty_tab(name VARCHAR(10))";
$statement = oci_parse($c, $create);
oci_execute($statement);


echo "Test 1\n";

$name = null;
$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
oci_bind_by_name($stmt, ":name", $name);

var_dump(oci_execute($stmt));

echo "Test 2\n";

$name = "";
$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
oci_bind_by_name($stmt, ":name", $name);

var_dump(oci_execute($stmt));

echo "Test 3\n";

$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
$res = oci_execute($stmt);

$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
$res = oci_execute($stmt);

$name = null;
$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
oci_bind_by_name($stmt, ":name", $name);

var_dump(oci_execute($stmt));

$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
oci_execute($stid);
oci_fetch_all($stid, $res);
var_dump($res);

echo "Test 4\n";

$name = "";
$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
oci_bind_by_name($stmt, ":name", $name);

var_dump(oci_execute($stmt));

$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
oci_execute($stid);
oci_fetch_all($stid, $res);
var_dump($res);

echo "Test 5\n";

$av = $bv = 'old';
$s = oci_parse($c, "begin :bv := null; end; ");
oci_bind_by_name($s, ":bv", $bv);
oci_execute($s);
var_dump($av);
var_dump($bv);

echo "Test 6\n";

$av = $bv = null;
$s = oci_parse($c, "begin :bv := null; end; ");
oci_bind_by_name($s, ":bv", $bv);
oci_execute($s);
var_dump($av);
var_dump($bv);

// Clean up

$drop = "DROP table bind_empty_tab";
$statement = oci_parse($c, $drop);
@oci_execute($statement);

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
Test 1
bool(true)
Test 2
bool(true)
Test 3
bool(true)
array(1) {
  ["NAME"]=>
  array(2) {
    [0]=>
    string(3) "def"
    [1]=>
    NULL
  }
}
Test 4
bool(true)
array(1) {
  ["NAME"]=>
  array(2) {
    [0]=>
    NULL
    [1]=>
    NULL
  }
}
Test 5
string(3) "old"
NULL
Test 6
NULL
NULL
===DONE===