@@ -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 | |
@@ -17,7 +17,7 @@ discard block  | 
                                                    ||
| 17 | 17 |  { | 
                                                        
| 18 | 18 | private $qb;  | 
                                                        
| 19 | 19 | |
| 20 | -    public function __construct(){ | 
                                                        |
| 20 | +    public function __construct() { | 
                                                        |
| 21 | 21 | $this->qb = new QueryBuilder();  | 
                                                        
| 22 | 22 | }  | 
                                                        
| 23 | 23 | |
@@ -35,7 +35,7 @@ discard block  | 
                                                    ||
| 35 | 35 | |
| 36 | 36 |          foreach ($conditions as $where) { | 
                                                        
| 37 | 37 | $sign = '=';  | 
                                                        
| 38 | -            if(count($where)==3) { | 
                                                        |
| 38 | +            if (count($where) == 3) { | 
                                                        |
| 39 | 39 | $sign = $where[1];  | 
                                                        
| 40 | 40 | }  | 
                                                        
| 41 | 41 |              if ($firstTime) { | 
                                                        
@@ -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)) { | 
                                                        
@@ -68,7 +68,7 @@  | 
                                                    ||
| 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).'.*';  | 
                                                        
@@ -287,8 +287,8 @@ discard block  | 
                                                    ||
| 287 | 287 | $this->results = $stmt->fetch(\PDO::FETCH_OBJ);  | 
                                                        
| 288 | 288 | |
| 289 | 289 |                  if(count($this->results) ){ | 
                                                        
| 290 | - // now turn this stdClass object to the object type of calling model  | 
                                                        |
| 291 | - $rows = $util->turnObject($this->className, $this->results);  | 
                                                        |
| 290 | + // now turn this stdClass object to the object type of calling model  | 
                                                        |
| 291 | + $rows = $util->turnObject($this->className, $this->results);  | 
                                                        |
| 292 | 292 | }  | 
                                                        
| 293 | 293 | // Reset class variables  | 
                                                        
| 294 | 294 | $this->reset();  | 
                                                        
@@ -298,7 +298,7 @@ discard block  | 
                                                    ||
| 298 | 298 | |
| 299 | 299 | $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC);  | 
                                                        
| 300 | 300 |              if(count($this->results) ){ | 
                                                        
| 301 | - $rows = $util->turnObjects($this->className, $this->results);  | 
                                                        |
| 301 | + $rows = $util->turnObjects($this->className, $this->results);  | 
                                                        |
| 302 | 302 | }  | 
                                                        
| 303 | 303 | // Reset class variables  | 
                                                        
| 304 | 304 | $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 | }  | 
                                                        
@@ -286,7 +286,7 @@ discard block  | 
                                                    ||
| 286 | 286 |              if ($fetchRows == 'first') { | 
                                                        
| 287 | 287 | $this->results = $stmt->fetch(\PDO::FETCH_OBJ);  | 
                                                        
| 288 | 288 | |
| 289 | -                if(count($this->results) ){ | 
                                                        |
| 289 | +                if (count($this->results)) { | 
                                                        |
| 290 | 290 | // now turn this stdClass object to the object type of calling model  | 
                                                        
| 291 | 291 | $rows = $util->turnObject($this->className, $this->results);  | 
                                                        
| 292 | 292 | }  | 
                                                        
@@ -297,7 +297,7 @@ discard block  | 
                                                    ||
| 297 | 297 | }  | 
                                                        
| 298 | 298 | |
| 299 | 299 | $this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC);  | 
                                                        
| 300 | -            if(count($this->results) ){ | 
                                                        |
| 300 | +            if (count($this->results)) { | 
                                                        |
| 301 | 301 | $rows = $util->turnObjects($this->className, $this->results);  | 
                                                        
| 302 | 302 | }  | 
                                                        
| 303 | 303 | // Reset class variables  | 
                                                        
@@ -382,7 +382,7 @@ discard block  | 
                                                    ||
| 382 | 382 | |
| 383 | 383 | $row = $this->first();  | 
                                                        
| 384 | 384 | |
| 385 | -        if($row == null ){ | 
                                                        |
| 385 | +        if ($row == null) { | 
                                                        |
| 386 | 386 |              throw new Exception("The record does not exists!"); | 
                                                        
| 387 | 387 | }  | 
                                                        
| 388 | 388 | |
@@ -410,9 +410,9 @@ discard block  | 
                                                    ||
| 410 | 410 | $qb = new QueryBuilder();  | 
                                                        
| 411 | 411 | $query = "TRUNCATE ".$this->table;  | 
                                                        
| 412 | 412 | |
| 413 | -        try{ | 
                                                        |
| 413 | +        try { | 
                                                        |
| 414 | 414 | Connection::get()->query($qb->queryPrefix($query));  | 
                                                        
| 415 | -        } catch(Exception $e){ | 
                                                        |
| 415 | +        } catch (Exception $e) { | 
                                                        |
| 416 | 416 | throw new Exception($e->getMessage());  | 
                                                        
| 417 | 417 | }  | 
                                                        
| 418 | 418 | |
@@ -448,14 +448,14 @@ discard block  | 
                                                    ||
| 448 | 448 | $query = "UPDATE ".$this->table." SET ";  | 
                                                        
| 449 | 449 | $ar = array();  | 
                                                        
| 450 | 450 | |
| 451 | -        foreach($row as $key => $val){ | 
                                                        |
| 451 | +        foreach ($row as $key => $val) { | 
                                                        |
| 452 | 452 | $ar[':'.$key] = $val;  | 
                                                        
| 453 | - $query.= $qb->quote($key)." =:".$key.",";  | 
                                                        |
| 453 | + $query .= $qb->quote($key)." =:".$key.",";  | 
                                                        |
| 454 | 454 | }  | 
                                                        
| 455 | 455 | |
| 456 | 456 | $query = rtrim($query, ",");  | 
                                                        
| 457 | 457 | |
| 458 | -        try{ | 
                                                        |
| 458 | +        try { | 
                                                        |
| 459 | 459 | $whereQuery = $wqb->buildAllWhereQuery(  | 
                                                        
| 460 | 460 | $this->where,  | 
                                                        
| 461 | 461 | $this->whereRaw,  | 
                                                        
@@ -464,11 +464,11 @@ discard block  | 
                                                    ||
| 464 | 464 | $this->whereNull,  | 
                                                        
| 465 | 465 | $this->whereNotNull  | 
                                                        
| 466 | 466 | );  | 
                                                        
| 467 | -            $query.= " ".join(" ", $whereQuery); | 
                                                        |
| 467 | +            $query .= " ".join(" ", $whereQuery); | 
                                                        |
| 468 | 468 | $stmt = Connection::get()->prepare($qb->queryPrefix($query));  | 
                                                        
| 469 | 469 | $stmt->execute($ar);  | 
                                                        
| 470 | 470 | $this->reset();  | 
                                                        
| 471 | -        } catch(Exception $e){ | 
                                                        |
| 471 | +        } catch (Exception $e) { | 
                                                        |
| 472 | 472 | throw new Exception($e->getMessage());  | 
                                                        
| 473 | 473 | }  | 
                                                        
| 474 | 474 | |
@@ -488,7 +488,7 @@ discard block  | 
                                                    ||
| 488 | 488 | $wqb = new WhereQueryBuilder();  | 
                                                        
| 489 | 489 | $query = "DELETE FROM ".$this->table;  | 
                                                        
| 490 | 490 | |
| 491 | -        try{ | 
                                                        |
| 491 | +        try { | 
                                                        |
| 492 | 492 | $whereQuery = $wqb->buildAllWhereQuery(  | 
                                                        
| 493 | 493 | $this->where,  | 
                                                        
| 494 | 494 | $this->whereRaw,  | 
                                                        
@@ -497,10 +497,10 @@ discard block  | 
                                                    ||
| 497 | 497 | $this->whereNull,  | 
                                                        
| 498 | 498 | $this->whereNotNull  | 
                                                        
| 499 | 499 | );  | 
                                                        
| 500 | -            $query.= " ".join(" ", $whereQuery); | 
                                                        |
| 500 | +            $query .= " ".join(" ", $whereQuery); | 
                                                        |
| 501 | 501 | Connection::get()->query($qb->queryPrefix($query));  | 
                                                        
| 502 | 502 | $this->reset();  | 
                                                        
| 503 | -        } catch(Exception $e){ | 
                                                        |
| 503 | +        } catch (Exception $e) { | 
                                                        |
| 504 | 504 | throw new Exception($e->getMessage());  | 
                                                        
| 505 | 505 | }  | 
                                                        
| 506 | 506 | |
@@ -17,48 +17,48 @@ discard block  | 
                                                    ||
| 17 | 17 | */  | 
                                                        
| 18 | 18 | class InsertQueryBuilder extends QueryBuilder  | 
                                                        
| 19 | 19 |  { | 
                                                        
| 20 | -    public function buildInsert($table, $obj){ | 
                                                        |
| 20 | +    public function buildInsert($table, $obj) { | 
                                                        |
| 21 | 21 | $qb = new QueryBuilder();  | 
                                                        
| 22 | 22 |          $query = "INSERT INTO ".$table." ("; | 
                                                        
| 23 | -        foreach($obj as $key => $val){ | 
                                                        |
| 24 | - $query.= $qb->quote($key).", ";  | 
                                                        |
| 23 | +        foreach ($obj as $key => $val) { | 
                                                        |
| 24 | + $query .= $qb->quote($key).", ";  | 
                                                        |
| 25 | 25 | }  | 
                                                        
| 26 | 26 | |
| 27 | 27 | $query = rtrim($query, ", ");  | 
                                                        
| 28 | - $query.= ") VALUES ";  | 
                                                        |
| 28 | + $query .= ") VALUES ";  | 
                                                        |
| 29 | 29 | |
| 30 | 30 | return $query;  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | 32 | |
| 33 | -    public function buildInsertPlaceholder($rows){ | 
                                                        |
| 33 | +    public function buildInsertPlaceholder($rows) { | 
                                                        |
| 34 | 34 | $ar = array();  | 
                                                        
| 35 | 35 |          $query = "("; | 
                                                        
| 36 | 36 | |
| 37 | -        foreach($rows as $key => $val){ | 
                                                        |
| 37 | +        foreach ($rows as $key => $val) { | 
                                                        |
| 38 | 38 | $ar[$key] = $val;  | 
                                                        
| 39 | - $query.= ":".$key.", ";  | 
                                                        |
| 39 | + $query .= ":".$key.", ";  | 
                                                        |
| 40 | 40 | }  | 
                                                        
| 41 | 41 | |
| 42 | 42 | $query = rtrim($query, ", ");  | 
                                                        
| 43 | - $query.=") ";  | 
                                                        |
| 43 | + $query .= ") ";  | 
                                                        |
| 44 | 44 | |
| 45 | 45 | return ['query' => $query, 'array' => $ar];  | 
                                                        
| 46 | 46 | }  | 
                                                        
| 47 | 47 | |
| 48 | -    public function buildInsertPlaceholders($rows){ | 
                                                        |
| 48 | +    public function buildInsertPlaceholders($rows) { | 
                                                        |
| 49 | 49 | $bindAr = array();  | 
                                                        
| 50 | 50 | $query = "";  | 
                                                        
| 51 | 51 | |
| 52 | -        foreach($rows as $i => $row){ | 
                                                        |
| 53 | -            $query.="("; | 
                                                        |
| 54 | -            foreach($row as $key => $val){ | 
                                                        |
| 55 | - $param = ":" . $key . $i;  | 
                                                        |
| 56 | - $query.= $param.", ";  | 
                                                        |
| 52 | +        foreach ($rows as $i => $row) { | 
                                                        |
| 53 | +            $query .= "("; | 
                                                        |
| 54 | +            foreach ($row as $key => $val) { | 
                                                        |
| 55 | + $param = ":".$key.$i;  | 
                                                        |
| 56 | + $query .= $param.", ";  | 
                                                        |
| 57 | 57 | $bindAr[$param] = $val;  | 
                                                        
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | 60 | $query = rtrim($query, ", ");  | 
                                                        
| 61 | - $query.="), ";  | 
                                                        |
| 61 | + $query .= "), ";  | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | 64 | $query = rtrim($query, ", ");  | 
                                                        
@@ -82,21 +82,21 @@ discard block  | 
                                                    ||
| 82 | 82 | $dataToBuild = $rows;  | 
                                                        
| 83 | 83 | $methodToCall = 'buildInsertPlaceholder';  | 
                                                        
| 84 | 84 | |
| 85 | -        if(is_array($rows) && isset($rows[0]) && is_array($rows[0])){ | 
                                                        |
| 85 | +        if (is_array($rows) && isset($rows[0]) && is_array($rows[0])) { | 
                                                        |
| 86 | 86 | $dataToBuild = $rows[0];  | 
                                                        
| 87 | 87 | $methodToCall = 'buildInsertPlaceholders';  | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
| 90 | 90 | $query = $this->buildInsert($table, $dataToBuild);  | 
                                                        
| 91 | 91 | $dataRet = $this->$methodToCall($rows);  | 
                                                        
| 92 | - $query.= $dataRet['query'];  | 
                                                        |
| 92 | + $query .= $dataRet['query'];  | 
                                                        |
| 93 | 93 | $bindAr = $dataRet['array'];  | 
                                                        
| 94 | 94 | |
| 95 | -        try{ | 
                                                        |
| 95 | +        try { | 
                                                        |
| 96 | 96 | $stmt = $db->prepare($qb->queryPrefix($query));  | 
                                                        
| 97 | 97 | |
| 98 | -            if(is_array($rows) && isset($rows[0]) && is_array($rows[0])){ | 
                                                        |
| 99 | -                foreach($bindAr as $param => $val){ | 
                                                        |
| 98 | +            if (is_array($rows) && isset($rows[0]) && is_array($rows[0])) { | 
                                                        |
| 99 | +                foreach ($bindAr as $param => $val) { | 
                                                        |
| 100 | 100 | $stmt->bindValue($param, $val);  | 
                                                        
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | |
| 107 | 107 | $stmt->execute($bindAr);  | 
                                                        
| 108 | 108 | return $db->lastInsertId();  | 
                                                        
| 109 | -        } catch(Exception $e){ | 
                                                        |
| 109 | +        } catch (Exception $e) { | 
                                                        |
| 110 | 110 | throw new Exception($e->getMessage());  | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | }  | 
                                                        
@@ -23,15 +23,15 @@  | 
                                                    ||
| 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 | - }  | 
                                                        |
| 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 | 33 | |
| 34 | - return ['ar' => $ar, 'query' => $query];  | 
                                                        |
| 34 | + return ['ar' => $ar, 'query' => $query];  | 
                                                        |
| 35 | 35 | }  | 
                                                        
| 36 | 36 |      public function createQuery($row){ | 
                                                        
| 37 | 37 | $ar = [];  | 
                                                        
@@ -22,34 +22,34 @@ 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 | |
| 34 | 34 | return ['ar' => $ar, 'query' => $query];  | 
                                                        
| 35 | 35 | }  | 
                                                        
| 36 | -    public function createQuery($row){ | 
                                                        |
| 36 | +    public function createQuery($row) { | 
                                                        |
| 37 | 37 | $ar = [];  | 
                                                        
| 38 | -        if(isset($row) && isset($row->id) && $row->id > 0 ){ | 
                                                        |
| 38 | +        if (isset($row) && isset($row->id) && $row->id > 0) { | 
                                                        |
| 39 | 39 | $query = "UPDATE ".$this->table." SET ";  | 
                                                        
| 40 | 40 | $mixedData = $this->buildQueryStrSingleFromArr($row);  | 
                                                        
| 41 | 41 | $query = rtrim($mixedData['query'], ",");  | 
                                                        
| 42 | -            $query.= " WHERE ".$this->qb->quote('id')."=:id"; | 
                                                        |
| 42 | +            $query .= " WHERE ".$this->qb->quote('id')."=:id"; | 
                                                        |
| 43 | 43 | |
| 44 | 44 | return ['query' => $query, 'data' => $mixedData['ar']];  | 
                                                        
| 45 | 45 | }  | 
                                                        
| 46 | 46 | |
| 47 | 47 | $queryVal = '';  | 
                                                        
| 48 | 48 |          $query = "INSERT INTO ".$this->table." ("; | 
                                                        
| 49 | -        foreach($row as $key => $val){ | 
                                                        |
| 50 | - $query.= $this->qb->quote($key).", ";  | 
                                                        |
| 49 | +        foreach ($row as $key => $val) { | 
                                                        |
| 50 | + $query .= $this->qb->quote($key).", ";  | 
                                                        |
| 51 | 51 | $ar[$key] = $val;  | 
                                                        
| 52 | - $queryVal.= ":".$key.", ";  | 
                                                        |
| 52 | + $queryVal .= ":".$key.", ";  | 
                                                        |
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | 55 |          $query = rtrim($query, ", ").") VALUES (".$queryVal.rtrim($query, ", ").") "; | 
                                                        
@@ -74,10 +74,10 @@ discard block  | 
                                                    ||
| 74 | 74 | |
| 75 | 75 | list($query, $data) = $this->createQuery($row);  | 
                                                        
| 76 | 76 | |
| 77 | -        try{ | 
                                                        |
| 77 | +        try { | 
                                                        |
| 78 | 78 | $stmt = Connection::get()->prepare($this->qb->queryPrefix($query));  | 
                                                        
| 79 | 79 | $stmt->execute($data);  | 
                                                        
| 80 | -        } catch(Exception $e){ | 
                                                        |
| 80 | +        } catch (Exception $e) { | 
                                                        |
| 81 | 81 | throw new Exception($e->getMessage());  | 
                                                        
| 82 | 82 | }  | 
                                                        
| 83 | 83 | |