travis: PHP-7.2+ debug builds require valgrind headers for PCRE
[m6w6/ext-pq] / tests / map001.phpt
1 --TEST--
2 map result
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $c = new pq\Connection(PQ_DSN);
12 $r = $c->exec("select (ARRAY['one','two','three','four','five','six','seven','eight','nine','ten'])[a] num, ".
13 "round(log(a)::numeric,3) log, round(exp(a)::numeric,3) exp from generate_series(1,10) a");
14 $r->fetchType = pq\Result::FETCH_OBJECT;
15
16 var_dump($r->map());
17 var_dump($r->map() == $r->map(0));
18 var_dump($r->map() == $r->map(0, array(0,1,2)));
19
20 $r = $c->exec("select * from generate_series(0,1) a, generate_series(0,1) b, generate_series(0,1) c, generate_series(0,1) d ".
21 "order by a,b,c,d");
22 $r->fetchType = pq\Result::FETCH_ARRAY;
23 var_dump($r->map(array(0,"b",2), "d"));
24
25 ?>
26 DONE
27 --EXPECTF--
28 Test
29 object(stdClass)#%d (10) {
30 ["one"]=>
31 object(stdClass)#%d (3) {
32 ["num"]=>
33 string(3) "one"
34 ["log"]=>
35 string(5) "0.000"
36 ["exp"]=>
37 string(5) "2.718"
38 }
39 ["two"]=>
40 object(stdClass)#%d (3) {
41 ["num"]=>
42 string(3) "two"
43 ["log"]=>
44 string(5) "0.301"
45 ["exp"]=>
46 string(5) "7.389"
47 }
48 ["three"]=>
49 object(stdClass)#%d (3) {
50 ["num"]=>
51 string(5) "three"
52 ["log"]=>
53 string(5) "0.477"
54 ["exp"]=>
55 string(6) "20.086"
56 }
57 ["four"]=>
58 object(stdClass)#%d (3) {
59 ["num"]=>
60 string(4) "four"
61 ["log"]=>
62 string(5) "0.602"
63 ["exp"]=>
64 string(6) "54.598"
65 }
66 ["five"]=>
67 object(stdClass)#%d (3) {
68 ["num"]=>
69 string(4) "five"
70 ["log"]=>
71 string(5) "0.699"
72 ["exp"]=>
73 string(7) "148.413"
74 }
75 ["six"]=>
76 object(stdClass)#%d (3) {
77 ["num"]=>
78 string(3) "six"
79 ["log"]=>
80 string(5) "0.778"
81 ["exp"]=>
82 string(7) "403.429"
83 }
84 ["seven"]=>
85 object(stdClass)#%d (3) {
86 ["num"]=>
87 string(5) "seven"
88 ["log"]=>
89 string(5) "0.845"
90 ["exp"]=>
91 string(8) "1096.633"
92 }
93 ["eight"]=>
94 object(stdClass)#%d (3) {
95 ["num"]=>
96 string(5) "eight"
97 ["log"]=>
98 string(5) "0.903"
99 ["exp"]=>
100 string(8) "2980.958"
101 }
102 ["nine"]=>
103 object(stdClass)#%d (3) {
104 ["num"]=>
105 string(4) "nine"
106 ["log"]=>
107 string(5) "0.954"
108 ["exp"]=>
109 string(8) "8103.084"
110 }
111 ["ten"]=>
112 object(stdClass)#%d (3) {
113 ["num"]=>
114 string(3) "ten"
115 ["log"]=>
116 string(5) "1.000"
117 ["exp"]=>
118 string(9) "22026.466"
119 }
120 }
121 bool(true)
122 bool(true)
123 array(2) {
124 [0]=>
125 array(2) {
126 [0]=>
127 array(2) {
128 [0]=>
129 array(1) {
130 [3]=>
131 string(1) "1"
132 }
133 [1]=>
134 array(1) {
135 [3]=>
136 string(1) "1"
137 }
138 }
139 [1]=>
140 array(2) {
141 [0]=>
142 array(1) {
143 [3]=>
144 string(1) "1"
145 }
146 [1]=>
147 array(1) {
148 [3]=>
149 string(1) "1"
150 }
151 }
152 }
153 [1]=>
154 array(2) {
155 [0]=>
156 array(2) {
157 [0]=>
158 array(1) {
159 [3]=>
160 string(1) "1"
161 }
162 [1]=>
163 array(1) {
164 [3]=>
165 string(1) "1"
166 }
167 }
168 [1]=>
169 array(2) {
170 [0]=>
171 array(1) {
172 [3]=>
173 string(1) "1"
174 }
175 [1]=>
176 array(1) {
177 [3]=>
178 string(1) "1"
179 }
180 }
181 }
182 }
183 DONE
184