xref: /PHP-8.3/ext/oci8/tests/field_funcs3.phpt (revision a53e5617)
1--TEST--
2oci_field_*() family: basic column types
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14// Initialization
15$stmtarray = array(
16    "drop table field_funcs3_tab",
17    "create table field_funcs3_tab(c1_c char(2), c2_v varchar2(2), c3_n number, c4_d date)",
18    "insert into field_funcs3_tab values ('c1', 'c2', 3, '01-Jan-2010')"
19);
20
21$v = oci_server_version($c);
22if (strpos($v, 'Oracle TimesTen') === false) {
23    oci8_test_sql_execute($c, array("alter session set nls_date_format = 'DD-MON-YYYY'"));
24}
25oci8_test_sql_execute($c, $stmtarray);
26
27// Run Test
28
29$select_sql = "select * from field_funcs3_tab";
30
31if (!($s = oci_parse($c, $select_sql))) {
32    die("oci_parse(select) failed!\n");
33}
34
35if (!oci_execute($s)) {
36    die("oci_execute(select) failed!\n");
37}
38
39$row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
40var_dump($row);
41
42foreach ($row as $num => $field) {
43    $num++;
44    var_dump(oci_field_is_null($s, $num));
45    var_dump(oci_field_name($s, $num));
46    var_dump(oci_field_type($s, $num));
47    var_dump(oci_field_type_raw($s, $num));
48    var_dump(oci_field_scale($s, $num));
49    var_dump(oci_field_precision($s, $num));
50    var_dump(oci_field_size($s, $num));
51}
52
53// Clean up
54
55$stmtarray = array(
56    "drop table field_funcs3_tab"
57);
58
59oci8_test_sql_execute($c, $stmtarray);
60
61?>
62--EXPECTF--
63array(4) {
64  [0]=>
65  string(2) "c1"
66  [1]=>
67  string(2) "c2"
68  [2]=>
69  string(1) "3"
70  [3]=>
71  string(1%r[19]%r) "%r(01-JAN-2010|0001-01-20 10:00:00)%r"
72}
73bool(false)
74string(4) "C1_C"
75string(4) "CHAR"
76int(96)
77int(0)
78int(0)
79int(2)
80bool(false)
81string(4) "C2_V"
82string(8) "VARCHAR2"
83int(1)
84int(0)
85int(0)
86int(2)
87bool(false)
88string(4) "C3_N"
89string(6) "NUMBER"
90int(2)
91int(-127)
92int(0)
93int(22)
94bool(false)
95string(4) "C4_D"
96string(4) "DATE"
97int(12)
98int(0)
99int(0)
100int(7)
101