1 | <?php |
||
20 | class ColumnQuery |
||
21 | { |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $columns = []; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $columnSelects = []; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $columnValues = []; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $columnFuncs = []; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $isCount = false; |
||
46 | |||
47 | /** |
||
48 | * @var Select |
||
49 | */ |
||
50 | protected $select; |
||
51 | |||
52 | /** |
||
53 | * @var JoinQuery |
||
54 | */ |
||
55 | protected $joinQuery; |
||
56 | |||
57 | /** |
||
58 | * @param Select $select |
||
59 | * @param JoinQuery $joinQuery |
||
60 | * @param array $columns |
||
61 | */ |
||
62 | public function __construct(Select $select, JoinQuery $joinQuery, array $columns = null) |
||
75 | |||
76 | /** |
||
77 | * @param $start |
||
78 | * @param int $count |
||
79 | * |
||
80 | * @return Select |
||
81 | */ |
||
82 | public function limit($start, $count = 0) |
||
86 | |||
87 | /** |
||
88 | * @param string $whereOperator |
||
89 | * |
||
90 | * @return \NilPortugues\Sql\QueryBuilder\Syntax\Where |
||
91 | */ |
||
92 | public function where($whereOperator = 'AND') |
||
96 | |||
97 | /** |
||
98 | * @param string $column |
||
99 | * @param string $direction |
||
100 | * @param null $table |
||
101 | * |
||
102 | * @return Select |
||
103 | */ |
||
104 | public function orderBy($column, $direction = OrderBy::ASC, $table = null) |
||
108 | |||
109 | /** |
||
110 | * @param string[] $columns |
||
111 | * |
||
112 | * @return Select |
||
113 | */ |
||
114 | public function groupBy(array $columns) |
||
118 | |||
119 | /** |
||
120 | * Allows setting a Select query as a column value. |
||
121 | * |
||
122 | * @param array $column |
||
123 | * |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function setSelectAsColumn(array $column) |
||
132 | |||
133 | /** |
||
134 | * @return array |
||
135 | */ |
||
136 | public function getColumnSelects() |
||
140 | |||
141 | /** |
||
142 | * Allows setting a value to the select statement. |
||
143 | * |
||
144 | * @param string $value |
||
145 | * @param string $alias |
||
146 | * |
||
147 | * @return $this |
||
148 | */ |
||
149 | public function setValueAsColumn($value, $alias) |
||
155 | |||
156 | /** |
||
157 | * @return array |
||
158 | */ |
||
159 | public function getColumnValues() |
||
163 | |||
164 | /** |
||
165 | * Allows calculation on columns using predefined SQL functions. |
||
166 | * |
||
167 | * @param string $funcName |
||
168 | * @param string[] $arguments |
||
169 | * @param string $alias |
||
170 | * |
||
171 | * @return $this |
||
172 | */ |
||
173 | public function setFunctionAsColumn($funcName, array $arguments, $alias) |
||
179 | |||
180 | /** |
||
181 | * @return array |
||
182 | */ |
||
183 | public function getColumnFuncs() |
||
187 | |||
188 | /** |
||
189 | * @param string $columnName |
||
190 | * @param string $alias |
||
191 | * |
||
192 | * @return $this |
||
193 | */ |
||
194 | public function count($columnName = '*', $alias = '') |
||
211 | |||
212 | /** |
||
213 | * @return bool |
||
214 | */ |
||
215 | public function isCount() |
||
219 | |||
220 | /** |
||
221 | * @return array |
||
222 | */ |
||
223 | public function getAllColumns() |
||
234 | |||
235 | /** |
||
236 | * @return \NilPortugues\Sql\QueryBuilder\Syntax\Column |
||
237 | * |
||
238 | * @throws QueryException |
||
239 | */ |
||
240 | public function getColumns() |
||
248 | |||
249 | /** |
||
250 | * Sets the column names used to write the SELECT statement. |
||
251 | * If key is set, key is the column's alias. Value is always the column names. |
||
252 | * |
||
253 | * @param array $columns |
||
254 | * |
||
255 | * @return $this |
||
256 | */ |
||
257 | public function setColumns(array $columns) |
||
263 | } |
||
264 |