1 | <?php |
||
18 | class Query implements QueryInterface |
||
19 | { |
||
20 | /* @var \PDO The PDO. */ |
||
21 | private $pdo; |
||
22 | |||
23 | /* @var array The bindings. */ |
||
24 | private $bindings; |
||
25 | |||
26 | /* @var QueryBuilder The query builder. */ |
||
27 | private $queryBuilder; |
||
28 | |||
29 | /** |
||
30 | * Construct a query object with the given pdo and table. |
||
31 | * |
||
32 | * @param \PDO $pdo |
||
33 | * @param string $table |
||
34 | */ |
||
35 | 21 | public function __construct(\PDO $pdo, $table) |
|
41 | |||
42 | /** |
||
43 | * Returns a string representation of the query object. |
||
44 | * |
||
45 | * @return string a string representation of the query object. |
||
46 | */ |
||
47 | 21 | public function __toString() |
|
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | 17 | public function select($columns = ['*']) |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 1 | public function insert(array $values) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 1 | public function update(array $values) |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 1 | public function delete() |
|
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | 1 | public function join($table, $primary, $operator, $secondary) |
|
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 1 | public function leftJoin($table, $primary, $operator, $secondary) |
|
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | 1 | public function rightJoin($table, $primary, $operator, $secondary) |
|
122 | |||
123 | /** |
||
124 | * {@inheritdoc} |
||
125 | */ |
||
126 | 1 | public function crossJoin($table, $primary, $operator, $secondary) |
|
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | 7 | public function where($column, $operator, $value) |
|
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | 1 | public function groupBy($column) |
|
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | 1 | public function orderBy($column, $order = null) |
|
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | 2 | public function limit($limit) |
|
176 | |||
177 | /** |
||
178 | * {@inheritdoc} |
||
179 | */ |
||
180 | 1 | public function offset($offset) |
|
186 | |||
187 | /** |
||
188 | * Returns the result of the executed prepared query. |
||
189 | * |
||
190 | * @return QueryResult the result of the executed prepared query. |
||
191 | */ |
||
192 | 4 | public function execute() |
|
206 | |||
207 | /** |
||
208 | * Returns the data type of the given value. |
||
209 | * |
||
210 | * @param mixed $value |
||
211 | * @return int the data type of the given value. |
||
212 | */ |
||
213 | 1 | private function getPdoDataType($value) |
|
227 | |||
228 | /** |
||
229 | * Returns a binding for the given clause and value. |
||
230 | * |
||
231 | * @param string $clause |
||
232 | * @param string $value |
||
233 | * @return string a binding for the given clause and value. |
||
234 | */ |
||
235 | 10 | private function addBinding($clause, $value) |
|
241 | |||
242 | /** |
||
243 | * Returns bindings for the given clause and values. |
||
244 | * |
||
245 | * @param string $clause |
||
246 | * @param array $values |
||
247 | * @return array bindings for the given clause and values. |
||
248 | */ |
||
249 | 3 | private function addBindings($clause, array $values) |
|
259 | |||
260 | /** |
||
261 | * Returns a binding for the given clause and value. |
||
262 | * |
||
263 | * @param string $clause |
||
264 | * @param string $value |
||
265 | * @return string a binding for the given clause and value. |
||
266 | */ |
||
267 | 2 | private function setBinding($clause, $value) |
|
271 | |||
272 | /** |
||
273 | * Returns bindings for the given clause and values. |
||
274 | * |
||
275 | * @param string $clause |
||
276 | * @param array $values |
||
277 | * @return array bindings for the given clause and values. |
||
278 | */ |
||
279 | 2 | private function setBindings($clause, array $values) |
|
283 | |||
284 | /** |
||
285 | * Remove the bindings that are associated with the given clause. |
||
286 | * |
||
287 | * @param string $clause |
||
288 | * @return $this |
||
289 | */ |
||
290 | 4 | private function removeBindings($clause) |
|
296 | } |
||
297 |