1 | <?php |
||
26 | class SelectQuery extends ProjectionQuery implements MapperProvider, IndexerProvider, Countable |
||
27 | { |
||
28 | use Mappers; |
||
29 | |||
30 | /** |
||
31 | * @var bool[] map where flag => true |
||
32 | */ |
||
33 | private $flags = []; |
||
34 | |||
35 | /** |
||
36 | * @var ReturnVars |
||
37 | */ |
||
38 | protected $return_vars; |
||
39 | |||
40 | /** |
||
41 | * @var string[] list of GROUP BY expressions |
||
42 | */ |
||
43 | protected $group_by = []; |
||
44 | |||
45 | /** |
||
46 | * @var string[] list of HAVING expressions |
||
47 | */ |
||
48 | protected $having = []; |
||
49 | |||
50 | /** |
||
51 | * @param Table $root |
||
52 | * @param Driver $driver |
||
53 | * @param TypeProvider $types |
||
54 | */ |
||
55 | 1 | public function __construct(Table $root, Driver $driver, TypeProvider $types) |
|
61 | |||
62 | /** |
||
63 | * Add all the Columns of a full Table to be selected and returned |
||
64 | * |
||
65 | * @param Table $table Table to select and return |
||
66 | * |
||
67 | * @return $this |
||
68 | */ |
||
69 | 1 | public function table(Table $table) |
|
75 | |||
76 | /** |
||
77 | * Add one or more Columns to select and return |
||
78 | * |
||
79 | * @param Column|Column[] one or more Columns to select and return |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | 1 | public function columns($cols) |
|
89 | |||
90 | /** |
||
91 | * Add an SQL expression to select and return |
||
92 | * |
||
93 | * @param string $expr return expression |
||
94 | * @param string|null $name return variable name (optional, but usually required) |
||
95 | * @param Type|string|null $type optional Type (or Type class-name) |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | 1 | public function value($expr, $name = null, $type = null) |
|
105 | |||
106 | /** |
||
107 | * Add an expression to apply to a GROUP BY clause |
||
108 | * |
||
109 | * @param Column|string $expr SQL expression (or Column object) to apply to the GROUP BY clause |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | 1 | public function groupBy($expr) |
|
119 | |||
120 | /** |
||
121 | * @param string|string[] $exprs one or more condition expressions to apply to the HAVING clause |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | 1 | public function having($exprs) |
|
133 | |||
134 | /** |
||
135 | * @inheritdoc |
||
136 | */ |
||
137 | 1 | public function getMappers() |
|
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | 1 | public function getIndexer() |
|
149 | |||
150 | /** |
||
151 | * @inheritdoc |
||
152 | */ |
||
153 | 1 | public function getSQL() |
|
185 | |||
186 | /** |
||
187 | * @internal do not call this method directly from client-code (see `Countable` interface) |
||
188 | * |
||
189 | * @ignore |
||
190 | * |
||
191 | * @see Connection::count() |
||
192 | * |
||
193 | * @return SelectQuery |
||
194 | */ |
||
195 | 1 | public function createCountStatement() |
|
212 | |||
213 | /** |
||
214 | * @ignore string magic (enables creation of nested SELECT queries) |
||
215 | */ |
||
216 | 1 | public function __toString() |
|
220 | |||
221 | /** |
||
222 | * @return string combined condition expression (for use in the WHERE clause of an SQL statement) |
||
223 | */ |
||
224 | 1 | protected function buildHaving() |
|
228 | |||
229 | /** |
||
230 | * @param string $flag |
||
231 | * @param bool $state |
||
232 | */ |
||
233 | 1 | protected function setFlag($flag, $state = true) |
|
241 | |||
242 | /** |
||
243 | * @return string query flags (such as "SQL_CALC_FOUND_ROWS" in a MySQL SELECT query) |
||
244 | */ |
||
245 | 1 | protected function buildFlags() |
|
249 | } |
||
250 |