@@ -87,7 +87,7 @@ |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | return $classname . ' {' . implode(', ', array_map( |
90 | - function ($p_0) use ($data) { |
|
90 | + function($p_0) use ($data) { |
|
91 | 91 | $p_0->setAccessible(true); |
92 | 92 | |
93 | 93 | return $p_0->getName() . ': ' . $p_0->getValue($data); |
@@ -164,7 +164,7 @@ |
||
164 | 164 | $prepare = empty($prepare) ? $this->prepare : $prepare; |
165 | 165 | return $prepare->rowCount(); |
166 | 166 | } catch (PDOException $e) { |
167 | - $this->setError($e);} |
|
167 | + $this->setError($e); } |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -132,8 +132,9 @@ |
||
132 | 132 | */ |
133 | 133 | protected function setTable(string $tableName, string $tableAlias = ""): self |
134 | 134 | { |
135 | - if (!empty($tableAlias)) |
|
136 | - $this->tableAlias = $tableAlias; |
|
135 | + if (!empty($tableAlias)) { |
|
136 | + $this->tableAlias = $tableAlias; |
|
137 | + } |
|
137 | 138 | $this->tableName = $tableName; |
138 | 139 | return $this; |
139 | 140 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function select(string $fields = '*', string $add = '', array $values = null, bool $returnModel = false, bool $debug = false) |
29 | 29 | { |
30 | - if (strlen($add) > 0) { |
|
30 | + if (strlen($add)>0) { |
|
31 | 31 | $add = ' ' . $add; |
32 | 32 | } |
33 | 33 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $numparams = substr($numparams, 1); |
67 | 67 | $sql = "INSERT INTO {$this->getTable()} ({$fields}) VALUES ({$numparams})"; |
68 | 68 | if ($debug) { |
69 | - echo $sql.'<pre>'.print_r($values).'</pre>'; |
|
69 | + echo $sql . '<pre>' . print_r($values) . '</pre>'; |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | $result = $this->executeSQL($sql, $values); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $sql .= " WHERE $where"; |
149 | 149 | } |
150 | 150 | if ($debug) { |
151 | - echo $sql.'<pre>'.print_r($values).'</pre>'; |
|
151 | + echo $sql . '<pre>' . print_r($values) . '</pre>'; |
|
152 | 152 | return; |
153 | 153 | } |
154 | 154 | $result = $this->executeSQL($sql, $values); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $sql .= " WHERE $where"; |
224 | 224 | } |
225 | 225 | if ($debug) { |
226 | - echo $sql.'<pre>'.print_r($values).'</pre>'; |
|
226 | + echo $sql . '<pre>' . print_r($values) . '</pre>'; |
|
227 | 227 | return; |
228 | 228 | } |
229 | 229 | $result = $this->executeSQL($sql, $values); |
@@ -33,8 +33,9 @@ |
||
33 | 33 | |
34 | 34 | $sql = "SELECT {$fields} FROM {$this->getTable()}"; |
35 | 35 | |
36 | - if (!empty($this->getTableAlias())) |
|
37 | - $sql .= " AS {$this->getTableAlias()}"; |
|
36 | + if (!empty($this->getTableAlias())) { |
|
37 | + $sql .= " AS {$this->getTableAlias()}"; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | $sql .= "{$add}"; |
40 | 41 |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | /** |
37 | 37 | * |
38 | - * <code> |
|
39 | - * $qb = $this->select('u.id, p.id') |
|
40 | - * ->where('phonenumbers=?', [$number]); |
|
41 | - * </code> |
|
42 | - * @param string $fields |
|
43 | - * @param array $paramns |
|
44 | - * @return $this |
|
38 | + * <code> |
|
39 | + * $qb = $this->select('u.id, p.id') |
|
40 | + * ->where('phonenumbers=?', [$number]); |
|
41 | + * </code> |
|
42 | + * @param string $fields |
|
43 | + * @param array $paramns |
|
44 | + * @return $this |
|
45 | 45 | */ |
46 | 46 | public function select(string $fields = "*", array $paramns = []): CrudBuilder |
47 | 47 | { |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | - * @param string $fields |
|
61 | - * @param array $paramns |
|
62 | - * @return $this |
|
60 | + * @param string $fields |
|
61 | + * @param array $paramns |
|
62 | + * @return $this |
|
63 | 63 | */ |
64 | 64 | public function insert(string $fields, array $paramns): self |
65 | 65 | { |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * @param string $fields |
|
82 | - * @param array $paramns |
|
83 | - * @return $this |
|
81 | + * @param string $fields |
|
82 | + * @param array $paramns |
|
83 | + * @return $this |
|
84 | 84 | */ |
85 | 85 | public function update(string $fields, array $paramns): self |
86 | 86 | { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | - * @param string $fields |
|
105 | - * @param array $paramns |
|
106 | - * @return $this |
|
104 | + * @param string $fields |
|
105 | + * @param array $paramns |
|
106 | + * @return $this |
|
107 | 107 | */ |
108 | 108 | public function delete(string $fields, array $paramns): self |
109 | 109 | { |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | - * @param string $query |
|
121 | - * @param array $paramns |
|
122 | - * @return $this |
|
120 | + * @param string $query |
|
121 | + * @param array $paramns |
|
122 | + * @return $this |
|
123 | 123 | */ |
124 | 124 | public function query(string $query, array $paramns = []): self |
125 | 125 | { |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * @param string $texto |
|
136 | - * @param array $paramns |
|
137 | - * @return $this |
|
135 | + * @param string $texto |
|
136 | + * @param array $paramns |
|
137 | + * @return $this |
|
138 | 138 | */ |
139 | 139 | public function where(string $texto, array $paramns = []): self |
140 | 140 | { |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * @param string $condition |
|
152 | - * @param array $paramns |
|
153 | - * @return $this |
|
151 | + * @param string $condition |
|
152 | + * @param array $paramns |
|
153 | + * @return $this |
|
154 | 154 | */ |
155 | 155 | public function andWhere(string $condition, array $paramns = []): self |
156 | 156 | { |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | - * @param string $texto |
|
168 | - * @param array $paramns |
|
169 | - * @return $this |
|
167 | + * @param string $texto |
|
168 | + * @param array $paramns |
|
169 | + * @return $this |
|
170 | 170 | */ |
171 | 171 | public function orWhere(string $texto, array $paramns = []): self |
172 | 172 | { |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | - * @param string $texto |
|
184 | - * @return $this |
|
183 | + * @param string $texto |
|
184 | + * @return $this |
|
185 | 185 | */ |
186 | 186 | public function orderBy(string $texto, $order = null): self |
187 | 187 | { |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | - * @param string $texto |
|
199 | - * @return $this |
|
198 | + * @param string $texto |
|
199 | + * @return $this |
|
200 | 200 | */ |
201 | 201 | public function limit(string $texto): self |
202 | 202 | { |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | - * @param string $texto |
|
210 | - * @return $this |
|
209 | + * @param string $texto |
|
210 | + * @return $this |
|
211 | 211 | */ |
212 | 212 | public function offset(string $texto): self |
213 | 213 | { |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * @param string $texto |
|
225 | - * @return $this |
|
224 | + * @param string $texto |
|
225 | + * @return $this |
|
226 | 226 | */ |
227 | 227 | public function groupBy(string $texto): self |
228 | 228 | { |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
239 | - * @param string $texto |
|
240 | - * @return $this |
|
239 | + * @param string $texto |
|
240 | + * @return $this |
|
241 | 241 | */ |
242 | 242 | public function having(string $texto): self |
243 | 243 | { |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | - * @param string $table |
|
285 | - * @param string $alias |
|
286 | - * @param string $codition |
|
287 | - * @return $this |
|
284 | + * @param string $table |
|
285 | + * @param string $alias |
|
286 | + * @param string $codition |
|
287 | + * @return $this |
|
288 | 288 | */ |
289 | 289 | public function innerJoin(string $table, string $alias, string $codition): self |
290 | 290 | { |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | - * @param string $table |
|
302 | - * @param string $alias |
|
303 | - * @param string $codition |
|
304 | - * @return $this |
|
301 | + * @param string $table |
|
302 | + * @param string $alias |
|
303 | + * @param string $codition |
|
304 | + * @return $this |
|
305 | 305 | */ |
306 | 306 | public function leftJoin(string $table, string $alias, string $codition): self |
307 | 307 | { |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | - * @param string $table |
|
319 | - * @param string $alias |
|
320 | - * @param string $codition |
|
321 | - * @return $this |
|
318 | + * @param string $table |
|
319 | + * @param string $alias |
|
320 | + * @param string $codition |
|
321 | + * @return $this |
|
322 | 322 | */ |
323 | 323 | public function rightJoin(string $table, string $alias, string $codition): self |
324 | 324 | { |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
359 | - * @return void |
|
359 | + * @return void |
|
360 | 360 | */ |
361 | 361 | public function debug() |
362 | 362 | { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | public function orderBy(string $texto, $order = null): self |
187 | 187 | { |
188 | 188 | try { |
189 | - $query = "ORDER BY {$texto} ".($order ?? 'ASC')." "; |
|
189 | + $query = "ORDER BY {$texto} " . ($order ?? 'ASC') . " "; |
|
190 | 190 | $this->add($query, "orderBy"); |
191 | 191 | return $this; |
192 | 192 | } catch (\PDOException $e) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | public function limit(string $texto): self |
202 | 202 | { |
203 | 203 | $query = "LIMIT {$texto}"; |
204 | - $this->add($query,"limit"); |
|
204 | + $this->add($query, "limit"); |
|
205 | 205 | return $this; |
206 | 206 | } |
207 | 207 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | { |
214 | 214 | try { |
215 | 215 | $query = "OFFSET {$texto}"; |
216 | - $this->add($query,"offset"); |
|
216 | + $this->add($query, "offset"); |
|
217 | 217 | return $this; |
218 | 218 | } catch (\PDOException $e) { |
219 | 219 | $this->setError($e); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | try { |
230 | 230 | $query = "GROUP BY {$texto}"; |
231 | - $this->add($query,"groupBy"); |
|
231 | + $this->add($query, "groupBy"); |
|
232 | 232 | return $this; |
233 | 233 | } catch (\PDOException $e) { |
234 | 234 | $this->setError($e); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | { |
244 | 244 | try { |
245 | 245 | $query = "HAVING {$texto}"; |
246 | - $this->add($query,"having"); |
|
246 | + $this->add($query, "having"); |
|
247 | 247 | return $this; |
248 | 248 | } catch (\PDOException $e) { |
249 | 249 | $this->setError($e); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | try { |
260 | 260 | $query = "AND {$texto}"; |
261 | - $this->add($query,"andHaving"); |
|
261 | + $this->add($query, "andHaving"); |
|
262 | 262 | return $this; |
263 | 263 | } catch (\PDOException $e) { |
264 | 264 | $this->setError($e); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | { |
274 | 274 | try { |
275 | 275 | $query = "OR {$codition}"; |
276 | - $this->add($query,"orHaving"); |
|
276 | + $this->add($query, "orHaving"); |
|
277 | 277 | return $this; |
278 | 278 | } catch (\PDOException $e) { |
279 | 279 | $this->setError($e); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | { |
291 | 291 | try { |
292 | 292 | $query = "INNER JOIN {$table} AS {$alias} ON $codition"; |
293 | - $this->add($query,"join"); |
|
293 | + $this->add($query, "join"); |
|
294 | 294 | return $this; |
295 | 295 | } catch (\PDOException $e) { |
296 | 296 | $this->setError($e); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | { |
308 | 308 | try { |
309 | 309 | $query = "LEFT JOIN {$table} AS {$alias} ON {$codition}"; |
310 | - $this->add($query,"join"); |
|
310 | + $this->add($query, "join"); |
|
311 | 311 | return $this; |
312 | 312 | } catch (\PDOException $e) { |
313 | 313 | $this->setError($e); |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | { |
325 | 325 | try { |
326 | 326 | $query = "RIGHT JOIN {$table} AS {$alias} ON $codition"; |
327 | - $this->add($query,"join"); |
|
327 | + $this->add($query, "join"); |
|
328 | 328 | return $this; |
329 | 329 | } catch (\PDOException $e) { |
330 | 330 | $this->setError($e); |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | public function executeQuery(): self |
338 | 338 | { |
339 | 339 | try { |
340 | - foreach ($this->sqlPartsSelect as $key => $part){ |
|
340 | + foreach ($this->sqlPartsSelect as $key => $part) { |
|
341 | 341 | if (is_array($part)) { |
342 | - foreach ($part as $item){ |
|
342 | + foreach ($part as $item) { |
|
343 | 343 | $this->query .= $item; |
344 | 344 | } |
345 | 345 | } else { |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | |
401 | 401 | private function add(string $text, string $type, array $params = []) |
402 | 402 | { |
403 | - $text = $text." "; |
|
403 | + $text = $text . " "; |
|
404 | 404 | try { |
405 | 405 | if (is_array($this->sqlPartsSelect[$type])) { |
406 | 406 | $this->sqlPartsSelect[$type][] = $text; |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | { |
48 | 48 | try { |
49 | 49 | $query = "SELECT {$fields} FROM {$this->getTable()}"; |
50 | - if (!empty($this->getTableAlias())) |
|
51 | - $query .= "AS {$this->getTableAlias()} "; |
|
50 | + if (!empty($this->getTableAlias())) { |
|
51 | + $query .= "AS {$this->getTableAlias()} "; |
|
52 | + } |
|
52 | 53 | $this->add($query, "main", $paramns); |
53 | 54 | return $this; |
54 | 55 | } catch (\PDOException $e) { |
@@ -408,8 +409,9 @@ discard block |
||
408 | 409 | $this->sqlPartsSelect[$type] = $text; |
409 | 410 | } |
410 | 411 | |
411 | - if (!empty($params)) |
|
412 | - $this->params = array_merge($this->params, $params); |
|
412 | + if (!empty($params)) { |
|
413 | + $this->params = array_merge($this->params, $params); |
|
414 | + } |
|
413 | 415 | } catch (\PDOException $e) { |
414 | 416 | $this->setError($e); |
415 | 417 | } |