@@ -290,8 +290,8 @@ |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | if(count($this->results) ){ |
| 293 | - // now turn this stdClass object to the object type of calling model |
|
| 294 | - $rows = $util->turnObjects($this->className, $this->results); |
|
| 293 | + // now turn this stdClass object to the object type of calling model |
|
| 294 | + $rows = $util->turnObjects($this->className, $this->results); |
|
| 295 | 295 | } |
| 296 | 296 | // Reset class variables |
| 297 | 297 | $this->reset(); |
@@ -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 | |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | public function where() |
| 138 | 138 | { |
| 139 | 139 | $args = func_get_args(); |
| 140 | - if(func_num_args()===2){ |
|
| 140 | + if (func_num_args() === 2) { |
|
| 141 | 141 | $this->where = array_merge($this->where, [[$args[0], '=', $args[1]]]); |
| 142 | 142 | return $this; |
| 143 | - } elseif(func_num_args()===3){ |
|
| 143 | + } elseif (func_num_args() === 3) { |
|
| 144 | 144 | $this->where = array_merge($this->where, [[$args[0], $args[1], $args[2]]]); |
| 145 | 145 | return $this; |
| 146 | 146 | } |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | if ($fetchRows == 'first') { |
| 287 | 287 | $this->results = $stmt->fetch(\PDO::FETCH_OBJ); |
| 288 | - } else{ |
|
| 288 | + } else { |
|
| 289 | 289 | $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if(count($this->results) ){ |
|
| 292 | + if (count($this->results)) { |
|
| 293 | 293 | // now turn this stdClass object to the object type of calling model |
| 294 | 294 | $rows = $util->turnObjects($this->className, $this->results); |
| 295 | 295 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | $row = $this->first(); |
| 377 | 377 | |
| 378 | - if($row == null ){ |
|
| 378 | + if ($row == null) { |
|
| 379 | 379 | throw new Exception("The record does not exists!"); |
| 380 | 380 | } |
| 381 | 381 | |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | $qb = new QueryBuilder(); |
| 404 | 404 | $query = "TRUNCATE ".$this->table; |
| 405 | 405 | |
| 406 | - try{ |
|
| 406 | + try { |
|
| 407 | 407 | Connection::get()->query($qb->queryPrefix($query)); |
| 408 | - } catch(Exception $e){ |
|
| 408 | + } catch (Exception $e) { |
|
| 409 | 409 | throw new Exception($e->getMessage()); |
| 410 | 410 | } |
| 411 | 411 | |
@@ -441,14 +441,14 @@ discard block |
||
| 441 | 441 | $query = "UPDATE ".$this->table." SET "; |
| 442 | 442 | $ar = array(); |
| 443 | 443 | |
| 444 | - foreach($row as $key => $val){ |
|
| 444 | + foreach ($row as $key => $val) { |
|
| 445 | 445 | $ar[':'.$key] = $val; |
| 446 | - $query.= $qb->quote($key)." =:".$key.","; |
|
| 446 | + $query .= $qb->quote($key)." =:".$key.","; |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | $query = rtrim($query, ","); |
| 450 | 450 | |
| 451 | - try{ |
|
| 451 | + try { |
|
| 452 | 452 | $whereQuery = $wqb->buildAllWhereQuery( |
| 453 | 453 | $this->where, |
| 454 | 454 | $this->whereRaw, |
@@ -457,11 +457,11 @@ discard block |
||
| 457 | 457 | $this->whereNull, |
| 458 | 458 | $this->whereNotNull |
| 459 | 459 | ); |
| 460 | - $query.= " ".join(" ", $whereQuery); |
|
| 460 | + $query .= " ".join(" ", $whereQuery); |
|
| 461 | 461 | $stmt = Connection::get()->prepare($qb->queryPrefix($query)); |
| 462 | 462 | $stmt->execute($ar); |
| 463 | 463 | $this->reset(); |
| 464 | - } catch(Exception $e){ |
|
| 464 | + } catch (Exception $e) { |
|
| 465 | 465 | throw new Exception($e->getMessage()); |
| 466 | 466 | } |
| 467 | 467 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $wqb = new WhereQueryBuilder(); |
| 482 | 482 | $query = "DELETE FROM ".$this->table; |
| 483 | 483 | |
| 484 | - try{ |
|
| 484 | + try { |
|
| 485 | 485 | $whereQuery = $wqb->buildAllWhereQuery( |
| 486 | 486 | $this->where, |
| 487 | 487 | $this->whereRaw, |
@@ -490,10 +490,10 @@ discard block |
||
| 490 | 490 | $this->whereNull, |
| 491 | 491 | $this->whereNotNull |
| 492 | 492 | ); |
| 493 | - $query.= " ".join(" ", $whereQuery); |
|
| 493 | + $query .= " ".join(" ", $whereQuery); |
|
| 494 | 494 | Connection::get()->query($qb->queryPrefix($query)); |
| 495 | 495 | $this->reset(); |
| 496 | - } catch(Exception $e){ |
|
| 496 | + } catch (Exception $e) { |
|
| 497 | 497 | throw new Exception($e->getMessage()); |
| 498 | 498 | } |
| 499 | 499 | |