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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
--TEST--
oci_num_*() family
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
require(__DIR__."/connect.inc");
// Initialize
$stmtarray = array(
"drop table num_tab",
"create table num_tab (id number, value number)",
);
oci8_test_sql_execute($c, $stmtarray);
// Run Test
echo "Test 1\n";
var_dump(ocirowcount());
var_dump(oci_num_rows());
var_dump(ocinumcols());
var_dump(oci_num_fields());
echo "Test 2\n";
$insert_sql = "insert into num_tab (id, value) values (1,1)";
if (!($s = oci_parse($c, $insert_sql))) {
die("oci_parse(insert) failed!\n");
}
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
for ($i = 0; $i<3; $i++) {
if (!oci_execute($s)) {
die("oci_execute(insert) failed!\n");
}
}
echo "Test 3\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
if (!oci_commit($c)) {
die("oci_commit() failed!\n");
}
echo "Test 4\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
// All rows
$select_sql = "select * from num_tab";
if (!($s = oci_parse($c, $select_sql))) {
die("oci_parse(select) failed!\n");
}
echo "Test 5a\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
echo "Test 5b\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
if (oci_fetch_all($s,$r) === false) {
die("oci_fetch_all(select) failed!\n");
}
echo "Test 5c\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
// One row
$select_sql = "SELECT id, value FROM num_tab WHERE ROWNUM < 2";
if (!($s = oci_parse($c, $select_sql))) {
die("oci_parse(select) failed!\n");
}
if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
if (oci_fetch_all($s,$r) === false) {
die("oci_fetch_all(select) failed!\n");
}
echo "Test 6\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
// No rows
$select_sql = "select id from num_tab where 1=0";
if (!($s = oci_parse($c, $select_sql))) {
die("oci_parse(select) failed!\n");
}
if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
if (oci_fetch_all($s,$r) === false) {
die("oci_fetch_all(select) failed!\n");
}
echo "Test 7\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
$delete_sql = "delete from num_tab";
if (!($s = oci_parse($c, $delete_sql))) {
die("oci_parse(delete) failed!\n");
}
if (!oci_execute($s)) {
die("oci_execute(delete) failed!\n");
}
echo "Test 8a\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
oci_commit($c);
echo "Test 8b\n";
var_dump(ocirowcount($s));
var_dump(oci_num_rows($s));
var_dump(ocinumcols($s));
var_dump(oci_num_fields($s));
// Cleanup
$stmtarray = array(
"drop table num_tab"
);
oci8_test_sql_execute($c, $stmtarray);
echo "Done\n";
?>
--EXPECTF--
Test 1
Warning: ocirowcount() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: oci_num_rows() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: ocinumcols() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: oci_num_fields() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Test 2
int(0)
int(0)
int(0)
int(0)
Test 3
int(1)
int(1)
int(0)
int(0)
Test 4
int(1)
int(1)
int(0)
int(0)
Test 5a
int(0)
int(0)
int(0)
int(0)
Test 5b
int(0)
int(0)
int(2)
int(2)
Test 5c
int(3)
int(3)
int(2)
int(2)
Test 6
int(1)
int(1)
int(2)
int(2)
Test 7
int(0)
int(0)
int(1)
int(1)
Test 8a
int(3)
int(3)
int(0)
int(0)
Test 8b
int(3)
int(3)
int(0)
int(0)
Done
|