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