Annotation of embedaddon/php/ext/oci8/tests/num.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: oci_num_*() family
3: --SKIPIF--
4: <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5: --FILE--
6: <?php
7:
8: require(dirname(__FILE__)."/connect.inc");
9:
10: // Initialize
11:
12: $stmtarray = array(
13: "drop table num_tab",
14: "create table num_tab (id number, value number)",
15: );
16:
17: oci8_test_sql_execute($c, $stmtarray);
18:
19: // Run Test
20:
21: echo "Test 1\n";
22: var_dump(ocirowcount());
23: var_dump(oci_num_rows());
24: var_dump(ocinumcols());
25: var_dump(oci_num_fields());
26:
27: echo "Test 2\n";
28: $insert_sql = "insert into num_tab (id, value) values (1,1)";
29: if (!($s = oci_parse($c, $insert_sql))) {
30: die("oci_parse(insert) failed!\n");
31: }
32:
33: var_dump(ocirowcount($s));
34: var_dump(oci_num_rows($s));
35: var_dump(ocinumcols($s));
36: var_dump(oci_num_fields($s));
37:
38: for ($i = 0; $i<3; $i++) {
39: if (!oci_execute($s)) {
40: die("oci_execute(insert) failed!\n");
41: }
42: }
43:
44: echo "Test 3\n";
45: var_dump(ocirowcount($s));
46: var_dump(oci_num_rows($s));
47: var_dump(ocinumcols($s));
48: var_dump(oci_num_fields($s));
49:
50: if (!oci_commit($c)) {
51: die("oci_commit() failed!\n");
52: }
53:
54: echo "Test 4\n";
55: var_dump(ocirowcount($s));
56: var_dump(oci_num_rows($s));
57: var_dump(ocinumcols($s));
58: var_dump(oci_num_fields($s));
59:
60: // All rows
61: $select_sql = "select * from num_tab";
62:
63: if (!($s = oci_parse($c, $select_sql))) {
64: die("oci_parse(select) failed!\n");
65: }
66:
67: echo "Test 5a\n";
68: var_dump(ocirowcount($s));
69: var_dump(oci_num_rows($s));
70: var_dump(ocinumcols($s));
71: var_dump(oci_num_fields($s));
72:
73: if (!oci_execute($s)) {
74: die("oci_execute(select) failed!\n");
75: }
76:
77: echo "Test 5b\n";
78: var_dump(ocirowcount($s));
79: var_dump(oci_num_rows($s));
80: var_dump(ocinumcols($s));
81: var_dump(oci_num_fields($s));
82:
83:
84: if (oci_fetch_all($s,$r) === false) {
85: die("oci_fetch_all(select) failed!\n");
86: }
87:
88: echo "Test 5c\n";
89: var_dump(ocirowcount($s));
90: var_dump(oci_num_rows($s));
91: var_dump(ocinumcols($s));
92: var_dump(oci_num_fields($s));
93:
94: // One row
95: $select_sql = "SELECT id, value FROM num_tab WHERE ROWNUM < 2";
96:
97: if (!($s = oci_parse($c, $select_sql))) {
98: die("oci_parse(select) failed!\n");
99: }
100:
101: if (!oci_execute($s)) {
102: die("oci_execute(select) failed!\n");
103: }
104:
105: if (oci_fetch_all($s,$r) === false) {
106: die("oci_fetch_all(select) failed!\n");
107: }
108:
109: echo "Test 6\n";
110: var_dump(ocirowcount($s));
111: var_dump(oci_num_rows($s));
112: var_dump(ocinumcols($s));
113: var_dump(oci_num_fields($s));
114:
115: // No rows
116: $select_sql = "select id from num_tab where 1=0";
117:
118: if (!($s = oci_parse($c, $select_sql))) {
119: die("oci_parse(select) failed!\n");
120: }
121:
122: if (!oci_execute($s)) {
123: die("oci_execute(select) failed!\n");
124: }
125:
126: if (oci_fetch_all($s,$r) === false) {
127: die("oci_fetch_all(select) failed!\n");
128: }
129:
130: echo "Test 7\n";
131: var_dump(ocirowcount($s));
132: var_dump(oci_num_rows($s));
133: var_dump(ocinumcols($s));
134: var_dump(oci_num_fields($s));
135:
136: $delete_sql = "delete from num_tab";
137:
138: if (!($s = oci_parse($c, $delete_sql))) {
139: die("oci_parse(delete) failed!\n");
140: }
141:
142: if (!oci_execute($s)) {
143: die("oci_execute(delete) failed!\n");
144: }
145:
146: echo "Test 8a\n";
147: var_dump(ocirowcount($s));
148: var_dump(oci_num_rows($s));
149: var_dump(ocinumcols($s));
150: var_dump(oci_num_fields($s));
151:
152:
153: oci_commit($c);
154:
155: echo "Test 8b\n";
156: var_dump(ocirowcount($s));
157: var_dump(oci_num_rows($s));
158: var_dump(ocinumcols($s));
159: var_dump(oci_num_fields($s));
160:
161:
162: // Cleanup
163:
164: $stmtarray = array(
165: "drop table num_tab"
166: );
167:
168: oci8_test_sql_execute($c, $stmtarray);
169:
170: echo "Done\n";
171:
172: ?>
173: --EXPECTF--
174: Test 1
175:
176: Warning: ocirowcount() expects exactly 1 parameter, 0 given in %s on line %d
177: NULL
178:
179: Warning: oci_num_rows() expects exactly 1 parameter, 0 given in %s on line %d
180: NULL
181:
182: Warning: ocinumcols() expects exactly 1 parameter, 0 given in %s on line %d
183: NULL
184:
185: Warning: oci_num_fields() expects exactly 1 parameter, 0 given in %s on line %d
186: NULL
187: Test 2
188: int(0)
189: int(0)
190: int(0)
191: int(0)
192: Test 3
193: int(1)
194: int(1)
195: int(0)
196: int(0)
197: Test 4
198: int(1)
199: int(1)
200: int(0)
201: int(0)
202: Test 5a
203: int(0)
204: int(0)
205: int(0)
206: int(0)
207: Test 5b
208: int(0)
209: int(0)
210: int(2)
211: int(2)
212: Test 5c
213: int(3)
214: int(3)
215: int(2)
216: int(2)
217: Test 6
218: int(1)
219: int(1)
220: int(2)
221: int(2)
222: Test 7
223: int(0)
224: int(0)
225: int(1)
226: int(1)
227: Test 8a
228: int(3)
229: int(3)
230: int(0)
231: int(0)
232: Test 8b
233: int(3)
234: int(3)
235: int(0)
236: int(0)
237: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>