xref: /PHP-8.1/ext/oci8/tests/field_funcs.phpt (revision b5a14e6c)
1--TEST--
2oci_field_*() family
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require __DIR__."/connect.inc";
14require __DIR__.'/create_table.inc';
15
16$insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
17
18if (!($s = oci_parse($c, $insert_sql))) {
19    die("oci_parse(insert) failed!\n");
20}
21
22for ($i = 0; $i<3; $i++) {
23    if (!oci_execute($s)) {
24        die("oci_execute(insert) failed!\n");
25    }
26}
27
28if (!oci_commit($c)) {
29    die("oci_commit() failed!\n");
30}
31
32$select_sql = "SELECT * FROM ".$schema."".$table_name."";
33
34if (!($s = oci_parse($c, $select_sql))) {
35    die("oci_parse(select) failed!\n");
36}
37
38if (!oci_execute($s)) {
39    die("oci_execute(select) failed!\n");
40}
41
42$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
43var_dump($row);
44
45foreach ($row as $num => $field) {
46    $num++;
47    var_dump(oci_field_is_null($s, $num));
48    var_dump(oci_field_name($s, $num));
49    var_dump(oci_field_type($s, $num));
50    var_dump(oci_field_type_raw($s, $num));
51    var_dump(oci_field_scale($s, $num));
52    var_dump(oci_field_precision($s, $num));
53    var_dump(oci_field_size($s, $num));
54}
55
56
57require __DIR__.'/drop_table.inc';
58
59echo "Done\n";
60
61?>
62--EXPECT--
63array(5) {
64  [0]=>
65  string(1) "1"
66  [1]=>
67  string(1) "1"
68  [2]=>
69  NULL
70  [3]=>
71  NULL
72  [4]=>
73  NULL
74}
75bool(false)
76string(2) "ID"
77string(6) "NUMBER"
78int(2)
79int(-127)
80int(0)
81int(22)
82bool(false)
83string(5) "VALUE"
84string(6) "NUMBER"
85int(2)
86int(-127)
87int(0)
88int(22)
89bool(true)
90string(4) "BLOB"
91string(4) "BLOB"
92int(113)
93int(0)
94int(0)
95int(4000)
96bool(true)
97string(4) "CLOB"
98string(4) "CLOB"
99int(112)
100int(0)
101int(0)
102int(4000)
103bool(true)
104string(6) "STRING"
105string(8) "VARCHAR2"
106int(1)
107int(0)
108int(0)
109int(10)
110Done
111