@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | protected $offset; |
73 | 73 | protected $results; |
74 | 74 | |
75 | - private function getFields(array $args, bool $quote = true){ |
|
75 | + private function getFields(array $args, bool $quote = true) { |
|
76 | 76 | $fldAr = array(); |
77 | 77 | $qb = new QueryBuilder(); |
78 | 78 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | return $fldAr; |
86 | 86 | } |
87 | 87 | |
88 | - private function validateArgsCount($noOfArgs){ |
|
89 | - if($noOfArgs<2 || $noOfArgs >3){ |
|
88 | + private function validateArgsCount($noOfArgs) { |
|
89 | + if ($noOfArgs < 2 || $noOfArgs > 3) { |
|
90 | 90 | throw new Exception('Where parameter contains invalid number of parameters', 1); |
91 | 91 | } |
92 | 92 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $this->validateArgsCount($noOfArgs); |
149 | 149 | |
150 | - if($noOfArgs===2){ |
|
150 | + if ($noOfArgs === 2) { |
|
151 | 151 | $this->where = array_merge($this->where, [[$args[0], '=', $args[1]]]); |
152 | 152 | return $this; |
153 | 153 | } |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | |
294 | 294 | if ($fetchRows == 'first') { |
295 | 295 | $this->results = $stmt->fetch(\PDO::FETCH_OBJ); |
296 | - } else{ |
|
296 | + } else { |
|
297 | 297 | $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
298 | 298 | } |
299 | 299 | |
300 | - if(count($this->results) ){ |
|
300 | + if (count($this->results)) { |
|
301 | 301 | // now turn this stdClass object to the object type of calling model |
302 | 302 | $rows = $util->turnObjects($this->className, $this->results); |
303 | 303 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | |
384 | 384 | $row = $this->first(); |
385 | 385 | |
386 | - if($row == null ){ |
|
386 | + if ($row == null) { |
|
387 | 387 | throw new Exception("The record does not exists!"); |
388 | 388 | } |
389 | 389 | |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | $qb = new QueryBuilder(); |
412 | 412 | $query = "TRUNCATE ".$this->table; |
413 | 413 | |
414 | - try{ |
|
414 | + try { |
|
415 | 415 | Connection::get()->query($qb->queryPrefix($query)); |
416 | - } catch(Exception $e){ |
|
416 | + } catch (Exception $e) { |
|
417 | 417 | throw new Exception($e->getMessage()); |
418 | 418 | } |
419 | 419 | |
@@ -449,14 +449,14 @@ discard block |
||
449 | 449 | $query = "UPDATE ".$this->table." SET "; |
450 | 450 | $ar = array(); |
451 | 451 | |
452 | - foreach($row as $key => $val){ |
|
452 | + foreach ($row as $key => $val) { |
|
453 | 453 | $ar[':'.$key] = $val; |
454 | - $query.= $qb->quote($key)." =:".$key.","; |
|
454 | + $query .= $qb->quote($key)." =:".$key.","; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | $query = rtrim($query, ","); |
458 | 458 | |
459 | - try{ |
|
459 | + try { |
|
460 | 460 | $whereQuery = $wqb->buildAllWhereQuery( |
461 | 461 | $this->where, |
462 | 462 | $this->whereRaw, |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | $this->whereNull, |
466 | 466 | $this->whereNotNull |
467 | 467 | ); |
468 | - $query.= " ".join(" ", $whereQuery); |
|
468 | + $query .= " ".join(" ", $whereQuery); |
|
469 | 469 | $stmt = Connection::get()->prepare($qb->queryPrefix($query)); |
470 | 470 | $stmt->execute($ar); |
471 | 471 | $this->reset(); |
472 | - } catch(Exception $e){ |
|
472 | + } catch (Exception $e) { |
|
473 | 473 | throw new Exception($e->getMessage()); |
474 | 474 | } |
475 | 475 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $wqb = new WhereQueryBuilder(); |
490 | 490 | $query = "DELETE FROM ".$this->table; |
491 | 491 | |
492 | - try{ |
|
492 | + try { |
|
493 | 493 | $whereQuery = $wqb->buildAllWhereQuery( |
494 | 494 | $this->where, |
495 | 495 | $this->whereRaw, |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | $this->whereNull, |
499 | 499 | $this->whereNotNull |
500 | 500 | ); |
501 | - $query.= " ".join(" ", $whereQuery); |
|
501 | + $query .= " ".join(" ", $whereQuery); |
|
502 | 502 | Connection::get()->query($qb->queryPrefix($query)); |
503 | 503 | $this->reset(); |
504 | - } catch(Exception $e){ |
|
504 | + } catch (Exception $e) { |
|
505 | 505 | throw new Exception($e->getMessage()); |
506 | 506 | } |
507 | 507 |