refactor auto conversion
[m6w6/ext-pq] / tests / types002.phpt
1 --TEST--
2 extended type support
3 --SKIPIF--
4 <?php
5 include "_skipif.inc";
6 if (!pq\Types::DEFINED) {
7 die("skip pq\\Types::DEFINED == false\n");
8 }
9 ?>
10 --INI--
11 date.timezone=UTC
12 --FILE--
13 <?php
14 echo "Test\n";
15
16 include "_setup.inc";
17
18 $c = new pq\Connection(PQ_DSN);
19 $r = $c->exec("SET timezone TO UTC; SELECT
20 NULL as null,
21 true as bool,
22 1::int2 as int2,
23 2::int4 as int4,
24 3::int8 as int8,
25 1.1::float4 as float4,
26 2.2::float8 as float8,
27 '2013-01-01'::date as date,
28 1::abstime as abstime,
29 '2013-01-01 01:01:01'::timestamp as timestamp,
30 '2013-01-01 01:01:01 UTC'::timestamptz as timestamptz,
31 array[array[1,2,3],array[4,5,6],array[NULL::int,NULL::int,NULL::int]] as intarray
32 ");
33 var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
34 ?>
35 DONE
36 --EXPECTF--
37 Test
38 array(12) {
39 ["null"]=>
40 NULL
41 ["bool"]=>
42 bool(true)
43 ["int2"]=>
44 int(1)
45 ["int4"]=>
46 int(2)
47 ["int8"]=>
48 int(3)
49 ["float4"]=>
50 float(1.1)
51 ["float8"]=>
52 float(2.2)
53 ["date"]=>
54 object(pq\DateTime)#%d (4) {
55 ["format"]=>
56 string(5) "Y-m-d"
57 ["date"]=>
58 string(%d) "2013-01-01 00:00:00%r(\.000000)?%r"
59 ["timezone_type"]=>
60 int(3)
61 ["timezone"]=>
62 string(3) "UTC"
63 }
64 ["abstime"]=>
65 object(pq\DateTime)#%d (4) {
66 ["format"]=>
67 string(11) "Y-m-d H:i:s"
68 ["date"]=>
69 string(%d) "1970-01-01 00:00:01%r(\.000000)?%r"
70 ["timezone_type"]=>
71 int(1)
72 ["timezone"]=>
73 string(6) "+00:00"
74 }
75 ["timestamp"]=>
76 object(pq\DateTime)#%d (4) {
77 ["format"]=>
78 string(13) "Y-m-d H:i:s.u"
79 ["date"]=>
80 string(%d) "2013-01-01 01:01:01%r(\.000000)?%r"
81 ["timezone_type"]=>
82 int(3)
83 ["timezone"]=>
84 string(3) "UTC"
85 }
86 ["timestamptz"]=>
87 object(pq\DateTime)#%d (4) {
88 ["format"]=>
89 string(14) "Y-m-d H:i:s.uO"
90 ["date"]=>
91 string(%d) "2013-01-01 01:01:01%r(\.000000)?%r"
92 ["timezone_type"]=>
93 int(1)
94 ["timezone"]=>
95 string(6) "+00:00"
96 }
97 ["intarray"]=>
98 array(3) {
99 [0]=>
100 array(3) {
101 [0]=>
102 int(1)
103 [1]=>
104 int(2)
105 [2]=>
106 int(3)
107 }
108 [1]=>
109 array(3) {
110 [0]=>
111 int(4)
112 [1]=>
113 int(5)
114 [2]=>
115 int(6)
116 }
117 [2]=>
118 array(3) {
119 [0]=>
120 NULL
121 [1]=>
122 NULL
123 [2]=>
124 NULL
125 }
126 }
127 }
128 DONE