| @@ -15,7 +15,7 @@ | ||
| 15 | 15 |          $dbCredentials = require('database.php'); | 
| 16 | 16 | $var = $arguments[0]; | 
| 17 | 17 | |
| 18 | -        if(array_key_exists($var, $dbCredentials)){ | |
| 18 | +        if (array_key_exists($var, $dbCredentials)) { | |
| 19 | 19 | return $dbCredentials[$var]; | 
| 20 | 20 | } | 
| 21 | 21 | |
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | |
| 27 | 27 | public function __call($method, $parameters) | 
| 28 | 28 |      { | 
| 29 | -        if($method== 'asArray'){ | |
| 29 | +        if ($method == 'asArray') { | |
| 30 | 30 | // $obj = new Utils(); | 
| 31 | 31 | } | 
| 32 | 32 | } | 
| @@ -50,16 +50,16 @@ | ||
| 50 | 50 | return $destination; | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | - /** | |
| 54 | - * Turn the stadClass object to the type of calling Model | |
| 55 | - * | |
| 56 | - * @param String $destination | |
| 57 | - * @param Object $sourceObject | |
| 58 | - * @return Object $destination | |
| 59 | - * | |
| 60 | - * @author RN Kushwaha <[email protected]> | |
| 61 | - * @since v0.0.5 | |
| 62 | - */ | |
| 53 | + /** | |
| 54 | + * Turn the stadClass object to the type of calling Model | |
| 55 | + * | |
| 56 | + * @param String $destination | |
| 57 | + * @param Object $sourceObject | |
| 58 | + * @return Object $destination | |
| 59 | + * | |
| 60 | + * @author RN Kushwaha <[email protected]> | |
| 61 | + * @since v0.0.5 | |
| 62 | + */ | |
| 63 | 63 | public function turnObjects($destination, $data) | 
| 64 | 64 |      { | 
| 65 | 65 | $destination = new $destination(); | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | public function turnObject($destination, $sourceObject) | 
| 29 | 29 |      { | 
| 30 | 30 | $destination = new $destination(); | 
| 31 | -        if(!is_object($sourceObject)){ | |
| 31 | +        if (!is_object($sourceObject)) { | |
| 32 | 32 | return $destination; | 
| 33 | 33 | } | 
| 34 | 34 | |
| @@ -44,7 +44,7 @@ discard block | ||
| 44 | 44 |              if ($destinationReflection->hasProperty($name)) { | 
| 45 | 45 | $propDest = $destinationReflection->getProperty($name); | 
| 46 | 46 | $propDest->setAccessible(true); | 
| 47 | - $propDest->setValue($destination,$value); | |
| 47 | + $propDest->setValue($destination, $value); | |
| 48 | 48 |              } else { | 
| 49 | 49 | $destination->$name = $value; | 
| 50 | 50 | } | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | public function turnObjects($destination, $data) | 
| 67 | 67 |      { | 
| 68 | 68 | $destination = new $destination(); | 
| 69 | -        if(count($data)){ | |
| 69 | +        if (count($data)) { | |
| 70 | 70 | $destination->data = json_decode(json_encode($data, true)); | 
| 71 | 71 | } | 
| 72 | 72 | |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | class WhereQueryParser | 
| 14 | 14 |  { | 
| 15 | 15 | |
| 16 | -    protected function prepareArrayForWhere($bindKey, $bindVal = null){ | |
| 16 | +    protected function prepareArrayForWhere($bindKey, $bindVal = null) { | |
| 17 | 17 | $ar = $conditionAr = array(); | 
| 18 | 18 | // expecting a string like 'status = :status' | 
| 19 | 19 |          if ($this->checkWherePrepareUsed($bindKey)) { | 
| @@ -23,16 +23,16 @@ | ||
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | 25 |      public function buildQueryStrSingleFromArr($row = array()){ | 
| 26 | - $ar = []; | |
| 27 | - $query = "UPDATE ".$this->table." SET "; | |
| 28 | -      foreach($row as $key => $val){ | |
| 29 | - $ar[':'.$key] = $val; | |
| 30 | - if($key == 'id') continue; | |
| 31 | - $query.= $this->qb->quote($key)." =:".$key.","; | |
| 32 | - } | |
| 33 | - $query = rtrim($query, ","); | |
| 26 | + $ar = []; | |
| 27 | + $query = "UPDATE ".$this->table." SET "; | |
| 28 | +        foreach($row as $key => $val){ | |
| 29 | + $ar[':'.$key] = $val; | |
| 30 | + if($key == 'id') continue; | |
| 31 | + $query.= $this->qb->quote($key)." =:".$key.","; | |
| 32 | + } | |
| 33 | + $query = rtrim($query, ","); | |
| 34 | 34 | |
| 35 | - return ['ar' => $ar, 'query' => $query]; | |
| 35 | + return ['ar' => $ar, 'query' => $query]; | |
| 36 | 36 | } | 
| 37 | 37 |      public function createQuery($row){ | 
| 38 | 38 | $ar = []; | 
| @@ -22,33 +22,33 @@ discard block | ||
| 22 | 22 | $this->qb = new QueryBuilder(); | 
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | -    public function buildQueryStrSingleFromArr($row = array()){ | |
| 25 | +    public function buildQueryStrSingleFromArr($row = array()) { | |
| 26 | 26 | $ar = []; | 
| 27 | 27 | $query = "UPDATE ".$this->table." SET "; | 
| 28 | -      foreach($row as $key => $val){ | |
| 28 | +      foreach ($row as $key => $val) { | |
| 29 | 29 | $ar[':'.$key] = $val; | 
| 30 | - if($key == 'id') continue; | |
| 31 | - $query.= $this->qb->quote($key)." =:".$key.","; | |
| 30 | + if ($key == 'id') continue; | |
| 31 | + $query .= $this->qb->quote($key)." =:".$key.","; | |
| 32 | 32 | } | 
| 33 | 33 | $query = rtrim($query, ","); | 
| 34 | 34 | |
| 35 | 35 | return ['ar' => $ar, 'query' => $query]; | 
| 36 | 36 | } | 
| 37 | -    public function createQuery($row){ | |
| 37 | +    public function createQuery($row) { | |
| 38 | 38 | $ar = []; | 
| 39 | -        if(isset($row) && isset($row->id) && $row->id > 0 ){ | |
| 39 | +        if (isset($row) && isset($row->id) && $row->id > 0) { | |
| 40 | 40 | $mixedData = $this->buildQueryStrSingleFromArr($row); | 
| 41 | -            $query= $mixedData['query']." WHERE ".$this->qb->quote('id')."=:id"; | |
| 41 | +            $query = $mixedData['query']." WHERE ".$this->qb->quote('id')."=:id"; | |
| 42 | 42 | |
| 43 | 43 | return ['query' => $query, 'data' => $mixedData['ar']]; | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | 46 | $queryVal = ''; | 
| 47 | 47 |          $query = "INSERT INTO ".$this->table." ("; | 
| 48 | -        foreach($row as $key => $val){ | |
| 49 | - $query.= $this->qb->quote($key).", "; | |
| 48 | +        foreach ($row as $key => $val) { | |
| 49 | + $query .= $this->qb->quote($key).", "; | |
| 50 | 50 | $ar[$key] = $val; | 
| 51 | - $queryVal.= ":".$key.", "; | |
| 51 | + $queryVal .= ":".$key.", "; | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 |          $query = rtrim($query, ", ").") VALUES (".$queryVal.rtrim($query, ", ").") "; | 
| @@ -73,10 +73,10 @@ discard block | ||
| 73 | 73 | |
| 74 | 74 | list($query, $data) = $this->createQuery($row); | 
| 75 | 75 | |
| 76 | -        try{ | |
| 76 | +        try { | |
| 77 | 77 | $stmt = Connection::get()->prepare($this->qb->queryPrefix($query)); | 
| 78 | 78 | $stmt->execute($data); | 
| 79 | -        } catch(Exception $e){ | |
| 79 | +        } catch (Exception $e) { | |
| 80 | 80 | throw new Exception($e->getMessage()); | 
| 81 | 81 | } | 
| 82 | 82 | |
| @@ -66,7 +66,7 @@ | ||
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 |      private function checkMultipleInsert($rows = array()){ | 
| 69 | - return is_array($rows) && isset($rows[0]) && is_array($rows[0]); | |
| 69 | + return is_array($rows) && isset($rows[0]) && is_array($rows[0]); | |
| 70 | 70 | } | 
| 71 | 71 | /** | 
| 72 | 72 | * It inserts the new rows | 
| @@ -16,55 +16,55 @@ discard block | ||
| 16 | 16 | */ | 
| 17 | 17 | class InsertQueryBuilder extends QueryBuilder | 
| 18 | 18 |  { | 
| 19 | -    private function buildInsert($table, $obj){ | |
| 19 | +    private function buildInsert($table, $obj) { | |
| 20 | 20 | $qb = new QueryBuilder(); | 
| 21 | 21 |          $query = "INSERT INTO ".$table." ("; | 
| 22 | -        foreach($obj as $key => $val){ | |
| 23 | - $query.= $qb->quote($key).", "; | |
| 22 | +        foreach ($obj as $key => $val) { | |
| 23 | + $query .= $qb->quote($key).", "; | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | $query = rtrim($query, ", "); | 
| 27 | - $query.= ") VALUES "; | |
| 27 | + $query .= ") VALUES "; | |
| 28 | 28 | |
| 29 | 29 | return $query; | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | -    private function buildInsertPlaceholder($rows){ | |
| 32 | +    private function buildInsertPlaceholder($rows) { | |
| 33 | 33 | $ar = array(); | 
| 34 | 34 |          $query = "("; | 
| 35 | 35 | |
| 36 | -        foreach($rows as $key => $val){ | |
| 36 | +        foreach ($rows as $key => $val) { | |
| 37 | 37 | $ar[$key] = $val; | 
| 38 | - $query.= ":".$key.", "; | |
| 38 | + $query .= ":".$key.", "; | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | $query = rtrim($query, ", "); | 
| 42 | - $query.=") "; | |
| 42 | + $query .= ") "; | |
| 43 | 43 | |
| 44 | 44 | return ['query' => $query, 'array' => $ar]; | 
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | -    private function buildInsertPlaceholders($rows){ | |
| 47 | +    private function buildInsertPlaceholders($rows) { | |
| 48 | 48 | $bindAr = array(); | 
| 49 | 49 | $query = ""; | 
| 50 | 50 | |
| 51 | -        foreach($rows as $i => $row){ | |
| 52 | -            $query.="("; | |
| 53 | -            foreach($row as $key => $val){ | |
| 54 | - $param = ":" . $key . $i; | |
| 55 | - $query.= $param.", "; | |
| 51 | +        foreach ($rows as $i => $row) { | |
| 52 | +            $query .= "("; | |
| 53 | +            foreach ($row as $key => $val) { | |
| 54 | + $param = ":".$key.$i; | |
| 55 | + $query .= $param.", "; | |
| 56 | 56 | $bindAr[$param] = $val; | 
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | $query = rtrim($query, ", "); | 
| 60 | - $query.="), "; | |
| 60 | + $query .= "), "; | |
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | 63 | $query = rtrim($query, ", "); | 
| 64 | 64 | return ['query' => $query, 'array' => $bindAr]; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | -    private function checkMultipleInsert($rows = array()){ | |
| 67 | +    private function checkMultipleInsert($rows = array()) { | |
| 68 | 68 | return is_array($rows) && isset($rows[0]) && is_array($rows[0]); | 
| 69 | 69 | } | 
| 70 | 70 | /** | 
| @@ -83,21 +83,21 @@ discard block | ||
| 83 | 83 | $dataToBuild = $rows; | 
| 84 | 84 | $methodToCall = 'buildInsertPlaceholder'; | 
| 85 | 85 | |
| 86 | -        if($this->checkMultipleInsert($rows)){ | |
| 86 | +        if ($this->checkMultipleInsert($rows)) { | |
| 87 | 87 | $dataToBuild = $rows[0]; | 
| 88 | 88 | $methodToCall = 'buildInsertPlaceholders'; | 
| 89 | 89 | } | 
| 90 | 90 | |
| 91 | 91 | $query = $this->buildInsert($table, $dataToBuild); | 
| 92 | 92 | $dataRet = $this->$methodToCall($rows); | 
| 93 | - $query.= $dataRet['query']; | |
| 93 | + $query .= $dataRet['query']; | |
| 94 | 94 | $bindAr = $dataRet['array']; | 
| 95 | 95 | |
| 96 | -        try{ | |
| 96 | +        try { | |
| 97 | 97 | $stmt = $db->prepare($this->queryPrefix($query)); | 
| 98 | 98 | |
| 99 | -            if($this->checkMultipleInsert($rows)){ | |
| 100 | -                foreach($bindAr as $param => $val){ | |
| 99 | +            if ($this->checkMultipleInsert($rows)) { | |
| 100 | +                foreach ($bindAr as $param => $val) { | |
| 101 | 101 | $stmt->bindValue($param, $val); | 
| 102 | 102 | } | 
| 103 | 103 | |
| @@ -107,7 +107,7 @@ discard block | ||
| 107 | 107 | |
| 108 | 108 | $stmt->execute($bindAr); | 
| 109 | 109 | return $db->lastInsertId(); | 
| 110 | -        } catch(Exception $e){ | |
| 110 | +        } catch (Exception $e) { | |
| 111 | 111 | throw new Exception($e->getMessage()); | 
| 112 | 112 | } | 
| 113 | 113 | } | 
| @@ -26,14 +26,14 @@ | ||
| 26 | 26 | * @since v0.0.5 | 
| 27 | 27 | */ | 
| 28 | 28 | public function update( | 
| 29 | - $row, | |
| 30 | - $table, | |
| 31 | - $where, | |
| 32 | - $whereRaw, | |
| 33 | - $whereIn, | |
| 34 | - $whereNotIn, | |
| 35 | - $whereNull, | |
| 36 | - $whereNotNull | |
| 29 | + $row, | |
| 30 | + $table, | |
| 31 | + $where, | |
| 32 | + $whereRaw, | |
| 33 | + $whereIn, | |
| 34 | + $whereNotIn, | |
| 35 | + $whereNull, | |
| 36 | + $whereNotNull | |
| 37 | 37 | ) | 
| 38 | 38 |      { | 
| 39 | 39 | $wqb = new WhereQueryBuilder(); | 
| @@ -40,14 +40,14 @@ discard block | ||
| 40 | 40 | $query = "UPDATE ".$table." SET "; | 
| 41 | 41 | $ar = array(); | 
| 42 | 42 | |
| 43 | -        foreach($row as $key => $val){ | |
| 43 | +        foreach ($row as $key => $val) { | |
| 44 | 44 | $ar[':'.$key] = $val; | 
| 45 | - $query.= $this->quote($key)." =:".$key.","; | |
| 45 | + $query .= $this->quote($key)." =:".$key.","; | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | $query = rtrim($query, ","); | 
| 49 | 49 | |
| 50 | -        try{ | |
| 50 | +        try { | |
| 51 | 51 | $whereQuery = $wqb->buildAllWhereQuery( | 
| 52 | 52 | $where, | 
| 53 | 53 | $whereRaw, | 
| @@ -56,10 +56,10 @@ discard block | ||
| 56 | 56 | $whereNull, | 
| 57 | 57 | $whereNotNull | 
| 58 | 58 | ); | 
| 59 | -            $query.= " ".join(" ", $whereQuery); | |
| 59 | +            $query .= " ".join(" ", $whereQuery); | |
| 60 | 60 | $stmt = Connection::get()->prepare($this->queryPrefix($query)); | 
| 61 | 61 | $stmt->execute($ar); | 
| 62 | -        } catch(Exception $e){ | |
| 62 | +        } catch (Exception $e) { | |
| 63 | 63 | throw new Exception($e->getMessage()); | 
| 64 | 64 | } | 
| 65 | 65 | |
| @@ -299,8 +299,8 @@ discard block | ||
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | 301 |              if(count($this->results) ){ | 
| 302 | - // now turn this stdClass object to the object type of calling model | |
| 303 | - $rows = $util->turnObjects($this->className, $this->results); | |
| 302 | + // now turn this stdClass object to the object type of calling model | |
| 303 | + $rows = $util->turnObjects($this->className, $this->results); | |
| 304 | 304 | } | 
| 305 | 305 | // Reset class variables | 
| 306 | 306 | $this->reset(); | 
| @@ -424,14 +424,14 @@ discard block | ||
| 424 | 424 | public function update($row) | 
| 425 | 425 |      { | 
| 426 | 426 | $result = (new UpdateQueryBuilder())->update( | 
| 427 | - $row, | |
| 428 | - $this->table, | |
| 429 | - $this->where, | |
| 430 | - $this->whereRaw, | |
| 431 | - $this->whereIn, | |
| 432 | - $this->whereNotIn, | |
| 433 | - $this->whereNull, | |
| 434 | - $this->whereNotNull | |
| 427 | + $row, | |
| 428 | + $this->table, | |
| 429 | + $this->where, | |
| 430 | + $this->whereRaw, | |
| 431 | + $this->whereIn, | |
| 432 | + $this->whereNotIn, | |
| 433 | + $this->whereNull, | |
| 434 | + $this->whereNotNull | |
| 435 | 435 | ); | 
| 436 | 436 | |
| 437 | 437 | $this->reset(); | 
| @@ -470,13 +470,13 @@ discard block | ||
| 470 | 470 | public function delete() | 
| 471 | 471 |      { | 
| 472 | 472 | $result = (new DeleteQueryBuilder())->delete( | 
| 473 | - $this->table, | |
| 474 | - $this->where, | |
| 475 | - $this->whereRaw, | |
| 476 | - $this->whereIn, | |
| 477 | - $this->whereNotIn, | |
| 478 | - $this->whereNull, | |
| 479 | - $this->whereNotNull | |
| 473 | + $this->table, | |
| 474 | + $this->where, | |
| 475 | + $this->whereRaw, | |
| 476 | + $this->whereIn, | |
| 477 | + $this->whereNotIn, | |
| 478 | + $this->whereNull, | |
| 479 | + $this->whereNotNull | |
| 480 | 480 | ); | 
| 481 | 481 | |
| 482 | 482 | $this->reset(); | 
| @@ -73,7 +73,7 @@ discard block | ||
| 73 | 73 | protected $offset; | 
| 74 | 74 | protected $results; | 
| 75 | 75 | |
| 76 | -    private function getFields(array $args, bool $quote = true){ | |
| 76 | +    private function getFields(array $args, bool $quote = true) { | |
| 77 | 77 | $fldAr = array(); | 
| 78 | 78 | $qb = new QueryBuilder(); | 
| 79 | 79 | |
| @@ -86,8 +86,8 @@ discard block | ||
| 86 | 86 | return $fldAr; | 
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | -    private function validateArgsCount($noOfArgs){ | |
| 90 | -        if($noOfArgs<2 || $noOfArgs >3){ | |
| 89 | +    private function validateArgsCount($noOfArgs) { | |
| 90 | +        if ($noOfArgs < 2 || $noOfArgs > 3) { | |
| 91 | 91 |              throw new Exception('Where parameter contains invalid number of parameters', 1); | 
| 92 | 92 | } | 
| 93 | 93 | } | 
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 | |
| 149 | 149 | $this->validateArgsCount($noOfArgs); | 
| 150 | 150 | |
| 151 | -        if($noOfArgs===2){ | |
| 151 | +        if ($noOfArgs === 2) { | |
| 152 | 152 | $this->where = array_merge($this->where, [[$args[0], '=', $args[1]]]); | 
| 153 | 153 | return $this; | 
| 154 | 154 | } | 
| @@ -294,11 +294,11 @@ discard block | ||
| 294 | 294 | |
| 295 | 295 |              if ($fetchRows == 'first') { | 
| 296 | 296 | $this->results = $stmt->fetch(\PDO::FETCH_OBJ); | 
| 297 | -            } else{ | |
| 297 | +            } else { | |
| 298 | 298 | $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC); | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | -            if(count($this->results) ){ | |
| 301 | +            if (count($this->results)) { | |
| 302 | 302 | // now turn this stdClass object to the object type of calling model | 
| 303 | 303 | $rows = $util->turnObjects($this->className, $this->results); | 
| 304 | 304 | } | 
| @@ -384,7 +384,7 @@ discard block | ||
| 384 | 384 | |
| 385 | 385 | $row = $this->first(); | 
| 386 | 386 | |
| 387 | -        if($row == null ){ | |
| 387 | +        if ($row == null) { | |
| 388 | 388 |              throw new Exception("The record does not exists!"); | 
| 389 | 389 | } | 
| 390 | 390 | |
| @@ -423,7 +423,7 @@ discard block | ||
| 423 | 423 | */ | 
| 424 | 424 | public function update($row) | 
| 425 | 425 |      { | 
| 426 | - $result = (new UpdateQueryBuilder())->update( | |
| 426 | + $result = (new UpdateQueryBuilder())->update( | |
| 427 | 427 | $row, | 
| 428 | 428 | $this->table, | 
| 429 | 429 | $this->where, | 
| @@ -451,9 +451,9 @@ discard block | ||
| 451 | 451 | $qb = new QueryBuilder(); | 
| 452 | 452 | $query = "TRUNCATE ".$this->table; | 
| 453 | 453 | |
| 454 | -        try{ | |
| 454 | +        try { | |
| 455 | 455 | Connection::get()->query($qb->queryPrefix($query)); | 
| 456 | -        } catch(Exception $e){ | |
| 456 | +        } catch (Exception $e) { | |
| 457 | 457 | throw new Exception($e->getMessage()); | 
| 458 | 458 | } | 
| 459 | 459 | |
| @@ -469,7 +469,7 @@ discard block | ||
| 469 | 469 | */ | 
| 470 | 470 | public function delete() | 
| 471 | 471 |      { | 
| 472 | - $result = (new DeleteQueryBuilder())->delete( | |
| 472 | + $result = (new DeleteQueryBuilder())->delete( | |
| 473 | 473 | $this->table, | 
| 474 | 474 | $this->where, | 
| 475 | 475 | $this->whereRaw, | 
| @@ -78,37 +78,37 @@ | ||
| 78 | 78 | } | 
| 79 | 79 | |
| 80 | 80 |      private function buildLimitQuery($limit, $offset, $query = array()){ | 
| 81 | - $limitQuery = []; | |
| 82 | -      if (!empty($limit)) { | |
| 83 | - $query[] = 'LIMIT'; | |
| 81 | + $limitQuery = []; | |
| 82 | +        if (!empty($limit)) { | |
| 83 | + $query[] = 'LIMIT'; | |
| 84 | 84 | |
| 85 | -          if (!empty($offset)) { | |
| 86 | - $query[] = $offset.','; | |
| 87 | - } | |
| 85 | +            if (!empty($offset)) { | |
| 86 | + $query[] = $offset.','; | |
| 87 | + } | |
| 88 | 88 | |
| 89 | - $query[] = $limit; | |
| 90 | - } | |
| 89 | + $query[] = $limit; | |
| 90 | + } | |
| 91 | 91 | |
| 92 | -      if (count($limitQuery)) { | |
| 93 | - $query = array_merge($query, $limitQuery); | |
| 94 | - } | |
| 95 | - return $query; | |
| 92 | +        if (count($limitQuery)) { | |
| 93 | + $query = array_merge($query, $limitQuery); | |
| 94 | + } | |
| 95 | + return $query; | |
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | 98 |      public function query($query, $fetchRows){ | 
| 99 | -      try { | |
| 100 | - $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ); | |
| 101 | - | |
| 102 | -          if ($fetchRows == 'count') { | |
| 103 | - $obj = $obj->fetchColumn(); | |
| 104 | - } | |
| 105 | - | |
| 106 | - return $obj; | |
| 107 | -      } catch (\PDOException $ex) { | |
| 108 | - throw new \PDOException($ex->getMessage(), 1); | |
| 109 | -      } catch (Exception $e) { | |
| 110 | - throw new Exception($e->getMessage(), 1); | |
| 111 | - } | |
| 99 | +        try { | |
| 100 | + $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ); | |
| 101 | + | |
| 102 | +            if ($fetchRows == 'count') { | |
| 103 | + $obj = $obj->fetchColumn(); | |
| 104 | + } | |
| 105 | + | |
| 106 | + return $obj; | |
| 107 | +        } catch (\PDOException $ex) { | |
| 108 | + throw new \PDOException($ex->getMessage(), 1); | |
| 109 | +        } catch (Exception $e) { | |
| 110 | + throw new Exception($e->getMessage(), 1); | |
| 111 | + } | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 | public function buildQuery(array $params) | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | return "'".$field."'"; | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | -    private function getQueryFields($fields, $tbl){ | |
| 71 | +    private function getQueryFields($fields, $tbl) { | |
| 72 | 72 |          $startQuery = join(', ', $fields); | 
| 73 | 73 |          if (empty($fields)) { | 
| 74 | 74 | $startQuery = $this->quote($tbl).'.*'; | 
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | return $startQuery; | 
| 78 | 78 | } | 
| 79 | 79 | |
| 80 | -    private function buildLimitQuery($limit, $offset, $query = array()){ | |
| 80 | +    private function buildLimitQuery($limit, $offset, $query = array()) { | |
| 81 | 81 | $limitQuery = []; | 
| 82 | 82 |        if (!empty($limit)) { | 
| 83 | 83 | $query[] = 'LIMIT'; | 
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | return $query; | 
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | -    public function query($query, $fetchRows){ | |
| 98 | +    public function query($query, $fetchRows) { | |
| 99 | 99 |        try { | 
| 100 | 100 | $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ); | 
| 101 | 101 | |