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