123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- --TEST--
- oci_num_*() family
- --SKIPIF--
- <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
- --FILE--
- <?php
- require(dirname(__FILE__)."/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
|