1 | <?php |
||
25 | class SelectQuery extends ProjectionQuery implements MapperProvider, Countable |
||
26 | { |
||
27 | use Mappers; |
||
28 | |||
29 | /** |
||
30 | * @var bool[] map where flag => true |
||
31 | */ |
||
32 | private $flags = []; |
||
33 | |||
34 | /** |
||
35 | * @var ReturnVars |
||
36 | */ |
||
37 | protected $return_vars; |
||
38 | |||
39 | /** |
||
40 | * @var string[] list of GROUP BY expressions |
||
41 | */ |
||
42 | protected $group_by = []; |
||
43 | |||
44 | /** |
||
45 | * @var string[] list of HAVING expressions |
||
46 | */ |
||
47 | protected $having = []; |
||
48 | |||
49 | /** |
||
50 | * @param Table $root |
||
51 | * @param Driver $driver |
||
52 | * @param TypeProvider $types |
||
53 | */ |
||
54 | 1 | public function __construct(Table $root, Driver $driver, TypeProvider $types) |
|
60 | |||
61 | /** |
||
62 | * Add all the Columns of a full Table to be selected and returned |
||
63 | * |
||
64 | * @param Table $table Table to select and return |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | 1 | public function table(Table $table) |
|
74 | |||
75 | /** |
||
76 | * Add one or more Columns to select and return |
||
77 | * |
||
78 | * @param Column|Column[] one or more Columns to select and return |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | 1 | public function columns($cols) |
|
88 | |||
89 | /** |
||
90 | * Add an SQL expression to select and return |
||
91 | * |
||
92 | * @param string $expr return expression |
||
93 | * @param string|null $name return variable name (optional, but usually required) |
||
94 | * @param Type|string|null $type optional Type (or Type class-name) |
||
95 | * |
||
96 | * @return $this |
||
97 | */ |
||
98 | 1 | public function value($expr, $name = null, $type = null) |
|
104 | |||
105 | /** |
||
106 | * Add an expression to apply to a GROUP BY clause |
||
107 | * |
||
108 | * @param Column|string $expr SQL expression (or Column object) to apply to the GROUP BY clause |
||
109 | * |
||
110 | * @return $this |
||
111 | */ |
||
112 | 1 | public function groupBy($expr) |
|
118 | |||
119 | /** |
||
120 | * @param string|string[] $exprs one or more condition expressions to apply to the HAVING clause |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | 1 | public function having($exprs) |
|
132 | |||
133 | /** |
||
134 | * @inheritdoc |
||
135 | */ |
||
136 | 1 | public function getMappers() |
|
140 | |||
141 | /** |
||
142 | * @inheritdoc |
||
143 | */ |
||
144 | 1 | public function getSQL() |
|
176 | |||
177 | /** |
||
178 | * @internal do not call this method directly from client-code (see `Countable` interface) |
||
179 | * |
||
180 | * @ignore |
||
181 | * |
||
182 | * @see Connection::count() |
||
183 | * |
||
184 | * @return SelectQuery |
||
185 | */ |
||
186 | 1 | public function createCountStatement() |
|
203 | |||
204 | /** |
||
205 | * @ignore string magic (enables creation of nested SELECT queries) |
||
206 | */ |
||
207 | 1 | public function __toString() |
|
211 | |||
212 | /** |
||
213 | * @return string combined condition expression (for use in the WHERE clause of an SQL statement) |
||
214 | */ |
||
215 | 1 | protected function buildHaving() |
|
219 | |||
220 | /** |
||
221 | * @param string $flag |
||
222 | * @param bool $state |
||
223 | */ |
||
224 | 1 | protected function setFlag($flag, $state = true) |
|
232 | |||
233 | /** |
||
234 | * @return string query flags (such as "SQL_CALC_FOUND_ROWS" in a MySQL SELECT query) |
||
235 | */ |
||
236 | 1 | protected function buildFlags() |
|
240 | } |
||
241 |