1 # array pq\Result::map([mixed $keys = 0[, mixed $vals = NULL]])
3 Fetch the complete result set as a simple map, a *multi dimensional array*, each dimension indexed by a column.
7 * Optional mixed $keys = 0
8 The the column indices/names used to index the map.
9 * Optional mixed $vals = NULL
10 The column indices/names which should build up the leaf entry of the map.
14 * array, the mapped columns.
18 * pq\Exception\InvalidArgumentException
19 * pq\Exception\BadMethodCallException
20 * pq\Exception\RuntimeException
27 $connection = new pq\Connection;
29 $result = $connection->exec("SELECT a,b,c from generate_series(1,3) a,
30 generate_series(4,6) b,
31 generate_series(7,9) c");
33 foreach($result->map(array(0,1,2)) as $a => $aa) {
34 foreach ($aa as $b => $bb) {
35 foreach ($bb as $c => $res) {
36 printf("%s,%s,%s = %s ", $a, $b, $c, implode(",", $res));
42 } catch (\pq\Exception $e) {
43 echo $e->getMessage(), "\n";
51 1,4,7 = 1,4,7 1,4,8 = 1,4,8 1,4,9 = 1,4,9
52 1,5,7 = 1,5,7 1,5,8 = 1,5,8 1,5,9 = 1,5,9
53 1,6,7 = 1,6,7 1,6,8 = 1,6,8 1,6,9 = 1,6,9
55 2,4,7 = 2,4,7 2,4,8 = 2,4,8 2,4,9 = 2,4,9 // This should help generate maps
56 2,5,7 = 2,5,7 2,5,8 = 2,5,8 2,5,9 = 2,5,9 // of f.e. statistical data with
57 2,6,7 = 2,6,7 2,6,8 = 2,6,8 2,6,9 = 2,6,9 // some GROUP BYs etc.
59 3,4,7 = 3,4,7 3,4,8 = 3,4,8 3,4,9 = 3,4,9
60 3,5,7 = 3,5,7 3,5,8 = 3,5,8 3,5,9 = 3,5,9
61 3,6,7 = 3,6,7 3,6,8 = 3,6,8 3,6,9 = 3,6,9