Merge pull request #33 from m6w6/fix-19
[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 ");
30 var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
31 ?>
32 DONE
33 --EXPECTF--
34 Test
35 array(12) {
36 ["null"]=>
37 NULL
38 ["bool"]=>
39 bool(true)
40 ["int2"]=>
41 int(1)
42 ["int4"]=>
43 int(2)
44 ["int8"]=>
45 int(3)
46 ["float4"]=>
47 float(1.1)
48 ["float8"]=>
49 float(2.2)
50 ["date"]=>
51 object(pq\DateTime)#%d (4) {
52 ["format"]=>
53 string(5) "Y-m-d"
54 ["date"]=>
55 string(%d) "2013-01-01 00:00:00%r(\.000000)?%r"
56 ["timezone_type"]=>
57 int(3)
58 ["timezone"]=>
59 string(3) "UTC"
60 }
61 ["timestamp"]=>
62 object(pq\DateTime)#%d (4) {
63 ["format"]=>
64 string(13) "Y-m-d H:i:s.u"
65 ["date"]=>
66 string(%d) "2013-01-01 01:01:01%r(\.000000)?%r"
67 ["timezone_type"]=>
68 int(3)
69 ["timezone"]=>
70 string(3) "UTC"
71 }
72 ["timestamptz"]=>
73 object(pq\DateTime)#%d (4) {
74 ["format"]=>
75 string(14) "Y-m-d H:i:s.uO"
76 ["date"]=>
77 string(%d) "2013-01-01 01:01:01%r(\.000000)?%r"
78 ["timezone_type"]=>
79 int(1)
80 ["timezone"]=>
81 string(6) "+00:00"
82 }
83 ["intarray"]=>
84 array(3) {
85 [0]=>
86 array(3) {
87 [0]=>
88 int(1)
89 [1]=>
90 int(2)
91 [2]=>
92 int(3)
93 }
94 [1]=>
95 array(3) {
96 [0]=>
97 int(4)
98 [1]=>
99 int(5)
100 [2]=>
101 int(6)
102 }
103 [2]=>
104 array(3) {
105 [0]=>
106 NULL
107 [1]=>
108 NULL
109 [2]=>
110 NULL
111 }
112 }
113 ["boxarray"]=>
114 array(2) {
115 [0]=>
116 string(11) "(2,3),(1,2)"
117 [1]=>
118 string(11) "(5,6),(4,5)"
119 }
120 }
121 DONE