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