Conditions | 4 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
32 | protected function buildUnions($query) { |
||
33 | $wrap = function ($query) { |
||
34 | $query = trim($query); |
||
35 | $query = join("\n\t", explode("\n", $query)); |
||
36 | return sprintf("(\n\t%s\n)", $query); |
||
37 | }; |
||
38 | $queries = [$wrap($query)]; |
||
39 | foreach($this->unions as $unionQuery) { |
||
40 | if($unionQuery[0] === 'ALL') { |
||
41 | $queries[] = 'UNION ALL'; |
||
42 | } else { |
||
43 | $queries[] = 'UNION'; |
||
44 | } |
||
45 | $queries[] = $wrap($unionQuery[1]); |
||
46 | } |
||
47 | if(count($queries) > 1) { |
||
48 | return join(" ", $queries); |
||
49 | } |
||
50 | return $query; |
||
51 | } |
||
52 | } |
||
53 |