xref: /PHP-8.3/ext/oci8/tests/field_funcs1.phpt (revision a53e5617)
1--TEST--
2oci_field_*() family: error cases
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14// Initialize
15
16$stmtarray = array(
17    "drop table field_funcs1_tab",
18    "create table field_funcs1_tab (id number, value number)",
19    "insert into field_funcs1_tab (id, value) values (1,1)",
20    "insert into field_funcs1_tab (id, value) values (1,1)",
21    "insert into field_funcs1_tab (id, value) values (1,1)"
22);
23
24oci8_test_sql_execute($c, $stmtarray);
25
26// Run Test
27
28if (!($s = oci_parse($c, "select * from field_funcs1_tab"))) {
29    die("oci_parse(select) failed!\n");
30}
31
32if (!oci_execute($s)) {
33    die("oci_execute(select) failed!\n");
34}
35
36$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
37var_dump($row);
38
39echo "Test 1\n";
40var_dump(oci_field_is_null($s, -1));
41var_dump(oci_field_name($s, -1));
42var_dump(oci_field_type($s, -1));
43var_dump(oci_field_type_raw($s, -1));
44var_dump(oci_field_scale($s, -1));
45var_dump(oci_field_precision($s, -1));
46var_dump(oci_field_size($s, -1));
47
48echo "Test 2\n";
49var_dump(oci_field_is_null($s, "none"));
50var_dump(oci_field_name($s, "none"));
51var_dump(oci_field_type($s, "none"));
52var_dump(oci_field_type_raw($s, "none"));
53var_dump(oci_field_scale($s, "none"));
54var_dump(oci_field_precision($s, "none"));
55var_dump(oci_field_size($s, "none"));
56
57// Cleanup
58
59$stmtarray = array(
60    "drop table field_funcs1_tab"
61);
62
63oci8_test_sql_execute($c, $stmtarray);
64
65echo "Done\n";
66
67?>
68--EXPECTF--
69array(2) {
70  [0]=>
71  string(1) "1"
72  [1]=>
73  string(1) "1"
74}
75Test 1
76
77Warning: oci_field_is_null(): Invalid column index "-1" in %s on line %d
78bool(false)
79
80Warning: oci_field_name(): Invalid column index "-1" in %s on line %d
81bool(false)
82
83Warning: oci_field_type(): Invalid column index "-1" in %s on line %d
84bool(false)
85
86Warning: oci_field_type_raw(): Invalid column index "-1" in %s on line %d
87bool(false)
88
89Warning: oci_field_scale(): Invalid column index "-1" in %s on line %d
90bool(false)
91
92Warning: oci_field_precision(): Invalid column index "-1" in %s on line %d
93bool(false)
94
95Warning: oci_field_size(): Invalid column index "-1" in %s on line %d
96bool(false)
97Test 2
98
99Warning: oci_field_is_null(): Invalid column name "none" in %s on line %d
100bool(false)
101
102Warning: oci_field_name(): Invalid column name "none" in %s on line %d
103bool(false)
104
105Warning: oci_field_type(): Invalid column name "none" in %s on line %d
106bool(false)
107
108Warning: oci_field_type_raw(): Invalid column name "none" in %s on line %d
109bool(false)
110
111Warning: oci_field_scale(): Invalid column name "none" in %s on line %d
112bool(false)
113
114Warning: oci_field_precision(): Invalid column name "none" in %s on line %d
115bool(false)
116
117Warning: oci_field_size(): Invalid column name "none" in %s on line %d
118bool(false)
119Done
120