test
[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 --FILE--
11 <?php
12 echo "Test\n";
13
14 include "_setup.inc";
15
16 $c = new pq\Connection(PQ_DSN);
17 $r = $c->exec("SET timezone TO UTC; SELECT
18 NULL as null,
19 true as bool,
20 1::int2 as int2,
21 2::int4 as int4,
22 3::int8 as int8,
23 1.1::float4 as float4,
24 2.2::float8 as float8,
25 '2013-01-01'::date as date,
26 1::abstime as abstime,
27 '2013-01-01 01:01:01'::timestamp as timestamp,
28 '2013-01-01 01:01:01 UTC'::timestamptz as timestamptz,
29 array[array[1,2,3],array[4,5,6],array[NULL::int,NULL::int,NULL::int]] as intarray
30 ");
31 var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
32 ?>
33 DONE
34 --EXPECTF--
35 Test
36 array(12) {
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(19) "2013-01-01 00:00:00"
57 ["timezone_type"]=>
58 int(3)
59 ["timezone"]=>
60 string(3) "UTC"
61 }
62 ["abstime"]=>
63 object(pq\DateTime)#%d (4) {
64 ["format"]=>
65 string(11) "Y-m-d H:i:s"
66 ["date"]=>
67 string(19) "1970-01-01 00:00:01"
68 ["timezone_type"]=>
69 int(1)
70 ["timezone"]=>
71 string(6) "+00:00"
72 }
73 ["timestamp"]=>
74 object(pq\DateTime)#%d (4) {
75 ["format"]=>
76 string(13) "Y-m-d H:i:s.u"
77 ["date"]=>
78 string(19) "2013-01-01 01:01:01"
79 ["timezone_type"]=>
80 int(3)
81 ["timezone"]=>
82 string(3) "UTC"
83 }
84 ["timestamptz"]=>
85 object(pq\DateTime)#%d (4) {
86 ["format"]=>
87 string(14) "Y-m-d H:i:s.uO"
88 ["date"]=>
89 string(19) "2013-01-01 01:01:01"
90 ["timezone_type"]=>
91 int(1)
92 ["timezone"]=>
93 string(6) "+00:00"
94 }
95 ["intarray"]=>
96 array(3) {
97 [0]=>
98 array(3) {
99 [0]=>
100 int(1)
101 [1]=>
102 int(2)
103 [2]=>
104 int(3)
105 }
106 [1]=>
107 array(3) {
108 [0]=>
109 int(4)
110 [1]=>
111 int(5)
112 [2]=>
113 int(6)
114 }
115 [2]=>
116 array(3) {
117 [0]=>
118 NULL
119 [1]=>
120 NULL
121 [2]=>
122 NULL
123 }
124 }
125 }
126 DONE