1 | <?php |
||
6 | class SelectBuilder extends AbstractBuilder |
||
7 | { |
||
8 | /** |
||
9 | * |
||
10 | * Builds the columns clause. |
||
11 | * |
||
12 | * @return string |
||
13 | * |
||
14 | * @throws Exception when there are no columns in the SELECT. |
||
15 | * |
||
16 | */ |
||
17 | 189 | public function buildCols($cols) |
|
18 | { |
||
19 | 189 | if (empty($cols)) { |
|
20 | 5 | throw new Exception('No columns in the SELECT.'); |
|
21 | } |
||
22 | 184 | return $this->indentCsv($cols); |
|
23 | } |
||
24 | |||
25 | /** |
||
26 | * |
||
27 | * Builds the FROM clause. |
||
28 | * |
||
29 | * @return string |
||
30 | * |
||
31 | */ |
||
32 | 184 | public function buildFrom($from, $join) |
|
33 | { |
||
34 | 184 | if (empty($from)) { |
|
35 | 60 | return ''; // not applicable |
|
36 | } |
||
37 | |||
38 | 124 | $refs = array(); |
|
39 | 124 | foreach ($from as $from_key => $from) { |
|
40 | 124 | if (isset($join[$from_key])) { |
|
41 | 55 | $from = array_merge($from, $join[$from_key]); |
|
42 | } |
||
43 | 124 | $refs[] = implode(PHP_EOL, $from); |
|
44 | } |
||
45 | 124 | return PHP_EOL . 'FROM' . $this->indentCsv($refs); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | * Builds the GROUP BY clause. |
||
51 | * |
||
52 | * @return string |
||
53 | * |
||
54 | */ |
||
55 | 184 | public function buildGroupBy($group_by) |
|
63 | |||
64 | /** |
||
65 | * |
||
66 | * Builds the HAVING clause. |
||
67 | * |
||
68 | * @return string |
||
69 | * |
||
70 | */ |
||
71 | 184 | public function buildHaving($having) |
|
79 | |||
80 | /** |
||
81 | * |
||
82 | * Builds the FOR UPDATE clause. |
||
83 | * |
||
84 | * @return string |
||
85 | * |
||
86 | */ |
||
87 | 184 | public function buildForUpdate($for_update) |
|
95 | } |
||
96 |