@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function PDO() |
| 34 | 34 | { |
| 35 | - if(empty($this->conn)) { |
|
| 35 | + if (empty($this->conn)) { |
|
| 36 | 36 | try { |
| 37 | 37 | $this->conn = new PDO( |
| 38 | 38 | $this->config['driver'] . ":host=" . |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->config['password'], |
| 45 | 45 | $this->config['options'] |
| 46 | 46 | ); |
| 47 | - } catch(PDOException $exception) { |
|
| 47 | + } catch (PDOException $exception) { |
|
| 48 | 48 | echo json_encode( |
| 49 | 49 | ['error' => |
| 50 | 50 | [ |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $sql->bindParam($data[$i], $values[$i]); |
| 58 | 58 | } |
| 59 | 59 | return $sql->execute(); |
| 60 | - } catch(PDOException $exception) { |
|
| 60 | + } catch (PDOException $exception) { |
|
| 61 | 61 | echo $exception->getMessage(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -70,20 +70,20 @@ discard block |
||
| 70 | 70 | public function insert(String $params, Array $values) |
| 71 | 71 | { |
| 72 | 72 | try { |
| 73 | - $parameters = "(".$params.")"; |
|
| 73 | + $parameters = "(" . $params . ")"; |
|
| 74 | 74 | $params = explode(',', $params); |
| 75 | 75 | $data = []; |
| 76 | 76 | $countParams = count($params); |
| 77 | - for($i = 0; $i < $countParams; $i++) { |
|
| 78 | - $data[$i] = ":". $params[$i] . $i; |
|
| 77 | + for ($i = 0; $i < $countParams; $i++) { |
|
| 78 | + $data[$i] = ":" . $params[$i] . $i; |
|
| 79 | 79 | } |
| 80 | - $valueBind = "(".implode(', ', $data).")"; |
|
| 80 | + $valueBind = "(" . implode(', ', $data) . ")"; |
|
| 81 | 81 | $sql = $this->conn->prepare("INSERT INTO {$this->table} $parameters VALUES $valueBind"); |
| 82 | - for($i = 0; $i < $countParams; $i++) { |
|
| 82 | + for ($i = 0; $i < $countParams; $i++) { |
|
| 83 | 83 | $sql->bindParam($data[$i], $values[$i]); |
| 84 | 84 | } |
| 85 | 85 | return $sql->execute(); |
| 86 | - } catch(PDOException $exception) { |
|
| 86 | + } catch (PDOException $exception) { |
|
| 87 | 87 | echo $exception->getCode(); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private function deny() |
| 150 | 150 | { |
| 151 | - if(!empty($this->excepts)) { |
|
| 152 | - foreach($this->excepts as $except) { |
|
| 153 | - if(isset($this->data[$except])) unset($this->data[$except]); |
|
| 151 | + if (!empty($this->excepts)) { |
|
| 152 | + foreach ($this->excepts as $except) { |
|
| 153 | + if (isset($this->data[$except])) unset($this->data[$except]); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $data = json_decode(json_encode($this->data), true); |
| 227 | 227 | if (empty($primary) || !isset($data[$primary])) { |
| 228 | 228 | $this->error("Índice primário não encontrado: {$primary}.", __FUNCTION__); |
| 229 | - } else if(!$this->find($data[$primary])->execute()) { |
|
| 229 | + } else if (!$this->find($data[$primary])->execute()) { |
|
| 230 | 230 | $this->error("Esse registro não consta no banco de dados: {$data[$primary]}.", __FUNCTION__); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | public function create() |
| 254 | 254 | { |
| 255 | 255 | $request = $this->request; |
| 256 | - if(empty($request)) { |
|
| 256 | + if (empty($request)) { |
|
| 257 | 257 | $this->error("O array request está vazio!", __FUNCTION__); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -269,6 +269,6 @@ discard block |
||
| 269 | 269 | * @return Error|null |
| 270 | 270 | */ |
| 271 | 271 | public function error(String $message, String $function): ?Error { |
| 272 | - if($message) { throw new Error($message." Método: ".strtoupper($function)); } else { return null; }; |
|
| 272 | + if ($message) { throw new Error($message . " Método: " . strtoupper($function)); } else { return null; }; |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | \ No newline at end of file |
@@ -150,7 +150,9 @@ |
||
| 150 | 150 | { |
| 151 | 151 | if(!empty($this->excepts)) { |
| 152 | 152 | foreach($this->excepts as $except) { |
| 153 | - if(isset($this->data[$except])) unset($this->data[$except]); |
|
| 153 | + if(isset($this->data[$except])) { |
|
| 154 | + unset($this->data[$except]); |
|
| 155 | + } |
|
| 154 | 156 | } |
| 155 | 157 | } |
| 156 | 158 | } |