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