| @@ -22,25 +22,25 @@ discard block | ||
| 22 | 22 | $this->qb = new QueryBuilder(); | 
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | -    public function createQuery($row){ | |
| 25 | +    public function createQuery($row) { | |
| 26 | 26 | $ar = []; | 
| 27 | -        if(isset($row) && isset($row->id) && $row->id > 0 ){ | |
| 27 | +        if (isset($row) && isset($row->id) && $row->id > 0) { | |
| 28 | 28 | $query = "UPDATE ".$this->table()." SET "; | 
| 29 | -            foreach($row as $key => $val){ | |
| 29 | +            foreach ($row as $key => $val) { | |
| 30 | 30 | $ar[':'.$key] = $val; | 
| 31 | - if($key == 'id') continue; | |
| 32 | - $query.= $this->qb->quote($key)." =:".$key.","; | |
| 31 | + if ($key == 'id') continue; | |
| 32 | + $query .= $this->qb->quote($key)." =:".$key.","; | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | 35 | $query = rtrim($query, ","); | 
| 36 | -            $query.= " WHERE ".$this->qb->quote('id')."=:id"; | |
| 37 | -        } else{ | |
| 36 | +            $query .= " WHERE ".$this->qb->quote('id')."=:id"; | |
| 37 | +        } else { | |
| 38 | 38 | $queryVal = ''; | 
| 39 | 39 |              $query = "INSERT INTO ".$this->table()." ("; | 
| 40 | -            foreach($row as $key => $val){ | |
| 41 | - $query.= $this->qb->quote($key).", "; | |
| 40 | +            foreach ($row as $key => $val) { | |
| 41 | + $query .= $this->qb->quote($key).", "; | |
| 42 | 42 | $ar[$key] = $val; | 
| 43 | - $queryVal.= ":".$key.", "; | |
| 43 | + $queryVal .= ":".$key.", "; | |
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | 46 |              $query = rtrim($query, ", ").") VALUES (".$queryVal.rtrim($query, ", ").") "; | 
| @@ -67,10 +67,10 @@ discard block | ||
| 67 | 67 | |
| 68 | 68 | list($query, $data) = $this->createQuery($row); | 
| 69 | 69 | |
| 70 | -        try{ | |
| 70 | +        try { | |
| 71 | 71 | $stmt = Connection::get()->prepare($qb->queryPrefix($query)); | 
| 72 | 72 | $stmt->execute($data); | 
| 73 | -        } catch(Exception $e){ | |
| 73 | +        } catch (Exception $e) { | |
| 74 | 74 | throw new Exception($e->getMessage()); | 
| 75 | 75 | } | 
| 76 | 76 | |
| @@ -28,7 +28,9 @@ | ||
| 28 | 28 | $query = "UPDATE ".$this->table()." SET "; | 
| 29 | 29 |              foreach($row as $key => $val){ | 
| 30 | 30 | $ar[':'.$key] = $val; | 
| 31 | - if($key == 'id') continue; | |
| 31 | +                if($key == 'id') { | |
| 32 | + continue; | |
| 33 | + } | |
| 32 | 34 | $query.= $this->qb->quote($key)." =:".$key.","; | 
| 33 | 35 | } | 
| 34 | 36 | |