1 | <?php |
||
24 | abstract class AbstractBaseQuery implements QueryInterface, QueryPartInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $comment = ''; |
||
30 | |||
31 | /** |
||
32 | * @var \NilPortugues\Sql\QueryBuilder\Builder\BuilderInterface |
||
33 | */ |
||
34 | private $builder; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $table; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $whereOperator = 'AND'; |
||
45 | |||
46 | /** |
||
47 | * @var Where |
||
48 | */ |
||
49 | protected $where; |
||
50 | |||
51 | /** |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $joins = []; |
||
55 | |||
56 | /** |
||
57 | * @var int |
||
58 | */ |
||
59 | protected $limitStart; |
||
60 | |||
61 | /** |
||
62 | * @var int |
||
63 | */ |
||
64 | protected $limitCount; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $orderBy = []; |
||
70 | |||
71 | /** |
||
72 | * @return Where |
||
73 | */ |
||
74 | protected function filter() |
||
82 | |||
83 | /** |
||
84 | * Stores the builder that created this query. |
||
85 | * |
||
86 | * @param BuilderInterface $builder |
||
87 | * |
||
88 | * @return $this |
||
89 | */ |
||
90 | final public function setBuilder(BuilderInterface $builder) |
||
96 | |||
97 | /** |
||
98 | * @return BuilderInterface |
||
99 | * |
||
100 | * @throws \RuntimeException when builder has not been injected |
||
101 | */ |
||
102 | final public function getBuilder() |
||
110 | |||
111 | /** |
||
112 | * Converts this query into an SQL string by using the injected builder. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function __toString() |
||
124 | |||
125 | /** |
||
126 | * Converts this query into an SQL string by using the injected builder. |
||
127 | * Optionally can return the SQL with formatted structure. |
||
128 | * |
||
129 | * @param bool $formatted |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | public function getSql($formatted = false) |
||
141 | |||
142 | /** |
||
143 | * @return string |
||
144 | */ |
||
145 | abstract public function partName(); |
||
146 | |||
147 | /** |
||
148 | * @return Where |
||
149 | */ |
||
150 | public function getWhere() |
||
154 | |||
155 | /** |
||
156 | * @return Table |
||
157 | */ |
||
158 | public function getTable() |
||
164 | |||
165 | /** |
||
166 | * @param string $table |
||
167 | * |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function setTable($table) |
||
176 | |||
177 | /** |
||
178 | * @param string $whereOperator |
||
179 | * |
||
180 | * @return Where |
||
181 | */ |
||
182 | public function where($whereOperator = 'AND') |
||
192 | |||
193 | /** |
||
194 | * @return string |
||
195 | */ |
||
196 | public function getWhereOperator() |
||
204 | |||
205 | /** |
||
206 | * @param string $column |
||
207 | * @param string $direction |
||
208 | * @param null $table |
||
209 | * |
||
210 | * @return $this |
||
211 | */ |
||
212 | public function orderBy($column, $direction = OrderBy::ASC, $table = null) |
||
220 | |||
221 | /** |
||
222 | * @return int |
||
223 | */ |
||
224 | public function getLimitCount() |
||
228 | |||
229 | /** |
||
230 | * @return int |
||
231 | */ |
||
232 | public function getLimitStart() |
||
236 | |||
237 | /** |
||
238 | * @param string $comment |
||
239 | * |
||
240 | * @return $this |
||
241 | */ |
||
242 | public function setComment($comment) |
||
257 | |||
258 | /** |
||
259 | * @return string |
||
260 | */ |
||
261 | public function getComment() |
||
265 | } |
||
266 |