1 | <?php |
||
16 | abstract class ProjectionQuery extends Query |
||
17 | { |
||
18 | /** |
||
19 | * @var Driver |
||
20 | */ |
||
21 | protected $driver; |
||
22 | |||
23 | /** |
||
24 | * @var Table root Table of this query (from which JOIN clauses may extend the projection) |
||
25 | */ |
||
26 | protected $root; |
||
27 | |||
28 | /** |
||
29 | * @var string[] list of JOIN clauses extending from the root Table of this query |
||
30 | */ |
||
31 | protected $joins = []; |
||
32 | |||
33 | /** |
||
34 | * @var string[] list of condition expressions to apply to the WHERE clause |
||
35 | */ |
||
36 | protected $conditions = []; |
||
37 | |||
38 | /** |
||
39 | * @var string[] list of ORDER BY terms |
||
40 | */ |
||
41 | protected $order = []; |
||
42 | |||
43 | /** |
||
44 | * @var int|null |
||
45 | */ |
||
46 | protected $offset; |
||
47 | |||
48 | /** |
||
49 | * @var int|null |
||
50 | */ |
||
51 | protected $limit; |
||
52 | |||
53 | /** |
||
54 | * @param Table $root |
||
55 | * @param Driver $driver |
||
56 | * @param TypeProvider $types |
||
57 | */ |
||
58 | 1 | public function __construct(Table $root, Driver $driver, TypeProvider $types) |
|
65 | |||
66 | /** |
||
67 | * @param string|string[] $exprs one or more condition expressions to apply to the WHERE clause |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | 1 | public function where($exprs) |
|
79 | |||
80 | /** |
||
81 | * @param string $expr order-by expression (which may include a trailing "ASC" or "DESC" modifier) |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | 1 | public function order($expr) |
|
91 | |||
92 | /** |
||
93 | * @param Table $table |
||
94 | * @param string $expr join condition |
||
95 | * |
||
96 | * @return $this |
||
97 | */ |
||
98 | 1 | public function innerJoin(Table $table, $expr) |
|
102 | |||
103 | /** |
||
104 | * @param Table $table |
||
105 | * @param string $expr join condition |
||
106 | * |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function leftJoin(Table $table, $expr) |
||
110 | { |
||
111 | return $this->join("LEFT", $table, $expr); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @param Table $table |
||
116 | * @param string $expr join condition |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | public function rightJoin(Table $table, $expr) |
||
121 | { |
||
122 | return $this->join("RIGHT", $table, $expr); |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @param int $limit max. number of records |
||
127 | * @param int|null $offset base-0 record number offset |
||
128 | * |
||
129 | * @return $this |
||
130 | * |
||
131 | * @throws InvalidArgumentException if the given limit is less than 1, or if the given offset if less than 0 |
||
132 | */ |
||
133 | 1 | public function limit($limit, $offset = null) |
|
148 | |||
149 | /** |
||
150 | * @param int $page_num base-1 page number |
||
151 | * @param int $page_size number of records per page |
||
152 | * |
||
153 | * @return $this |
||
154 | * |
||
155 | * @throws InvalidArgumentException if the given page number or page size are less than 1 |
||
156 | */ |
||
157 | 1 | public function page($page_num, $page_size) |
|
169 | |||
170 | /** |
||
171 | * @param string $type join type ("INNER", "LEFT", etc.) |
||
172 | * @param Table $table |
||
173 | * @param string $expr join condition |
||
174 | * |
||
175 | * @return $this |
||
176 | */ |
||
177 | 1 | protected function join($type, Table $table, $expr) |
|
185 | |||
186 | /** |
||
187 | * @return string root table expression and JOIN clauses (for use in the FROM clause of an SQL statement) |
||
188 | */ |
||
189 | 1 | protected function buildNodes() |
|
193 | |||
194 | /** |
||
195 | * @return string combined condition expression (for use in the WHERE clause of an SQL statement) |
||
196 | */ |
||
197 | 1 | protected function buildConditions() |
|
201 | |||
202 | /** |
||
203 | * @return string order terms (for use in the ORDER BY clause of an SQL statement) |
||
204 | */ |
||
205 | 1 | protected function buildOrderTerms() |
|
209 | |||
210 | /** |
||
211 | * @return string the LIMIT/OFFSET clause (or an empty string, if no limit has been set) |
||
212 | */ |
||
213 | protected function buildLimit() |
||
219 | } |
||
220 |