prepare v2.2.3
[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 'foo\n'::bytea as bytea,
31 'foo\n'::bytea::text as bytea_text
32 ");
33 var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
34 ?>
35 DONE
36 --EXPECTF--
37 Test
38 array(15) {
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 ["timestamp"]=>
65 object(pq\DateTime)#%d (4) {
66 ["format"]=>
67 string(13) "Y-m-d H:i:s.u"
68 ["date"]=>
69 string(%d) "2013-01-01 01:01:01%r(\.000000)?%r"
70 ["timezone_type"]=>
71 int(3)
72 ["timezone"]=>
73 string(3) "UTC"
74 }
75 ["timestamptz"]=>
76 object(pq\DateTime)#%d (4) {
77 ["format"]=>
78 string(14) "Y-m-d H:i:s.uO"
79 ["date"]=>
80 string(%d) "2013-01-01 01:01:01%r(\.000000)?%r"
81 ["timezone_type"]=>
82 int(1)
83 ["timezone"]=>
84 string(6) "+00:00"
85 }
86 ["intarray"]=>
87 array(3) {
88 [0]=>
89 array(3) {
90 [0]=>
91 int(1)
92 [1]=>
93 int(2)
94 [2]=>
95 int(3)
96 }
97 [1]=>
98 array(3) {
99 [0]=>
100 int(4)
101 [1]=>
102 int(5)
103 [2]=>
104 int(6)
105 }
106 [2]=>
107 array(3) {
108 [0]=>
109 NULL
110 [1]=>
111 NULL
112 [2]=>
113 NULL
114 }
115 }
116 ["boxarray"]=>
117 array(2) {
118 [0]=>
119 string(11) "(2,3),(1,2)"
120 [1]=>
121 string(11) "(5,6),(4,5)"
122 }
123 ["emptyarray"]=>
124 array(0) {
125 }
126 ["bytea"]=>
127 string(4) "foo
128 "
129 ["bytea_text"]=>
130 string(10) "\x666f6f0a"
131 }
132 DONE