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