@@ -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 | [ |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | */ |
180 | 180 | private function deny() |
181 | 181 | { |
182 | - if(!empty($this->excepts)) { |
|
182 | + if (!empty($this->excepts)) { |
|
183 | 183 | switch (!is_object($this->data) && $count = count($this->data)) { |
184 | 184 | case (!isset($this->data[0]) && !empty($this->data)): |
185 | - foreach($this->excepts as $except) { |
|
186 | - if(isset($this->data[$except])) { |
|
185 | + foreach ($this->excepts as $except) { |
|
186 | + if (isset($this->data[$except])) { |
|
187 | 187 | unset($this->data[$except]); |
188 | 188 | } |
189 | 189 | } |
190 | 190 | break; |
191 | 191 | case ($count >= 2 && isset($this->data[0])): |
192 | - foreach($this->excepts as $except) { |
|
193 | - for($i = 0; $i < $count; $i++) { |
|
194 | - if(isset($this->data[$i][$except])) { |
|
192 | + foreach ($this->excepts as $except) { |
|
193 | + for ($i = 0; $i < $count; $i++) { |
|
194 | + if (isset($this->data[$i][$except])) { |
|
195 | 195 | unset($this->data[$i][$except]); |
196 | 196 | } |
197 | 197 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $data = json_decode(json_encode($this->data), true); |
243 | 243 | if (empty($primary) || !isset($data[$primary])) { |
244 | 244 | $this->error("Índice primário não encontrado: {$primary}.", __FUNCTION__); |
245 | - } else if(!$this->find($data[$primary])->execute()) { |
|
245 | + } else if (!$this->find($data[$primary])->execute()) { |
|
246 | 246 | $this->error("Esse registro não consta no banco de dados: {$data[$primary]}.", __FUNCTION__); |
247 | 247 | } |
248 | 248 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | public function create() |
270 | 270 | { |
271 | 271 | $request = $this->request; |
272 | - if(empty($request)) { |
|
272 | + if (empty($request)) { |
|
273 | 273 | $this->error("O array request está vazio!", __FUNCTION__); |
274 | 274 | } |
275 | 275 | |
@@ -285,6 +285,6 @@ discard block |
||
285 | 285 | * @return Error|null |
286 | 286 | */ |
287 | 287 | public function error(String $message, String $function): ?Error { |
288 | - if($message) { throw new Error($message." Método: ".strtoupper($function)); } else { return null; }; |
|
288 | + if ($message) { throw new Error($message . " Método: " . strtoupper($function)); } else { return null; }; |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | \ No newline at end of file |
@@ -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,19 +70,19 @@ 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 | - for($i = 0; $i < count($params); $i++) { |
|
77 | - $data[$i] = ":". $params[$i] . $i; |
|
76 | + for ($i = 0; $i < count($params); $i++) { |
|
77 | + $data[$i] = ":" . $params[$i] . $i; |
|
78 | 78 | } |
79 | - $valueBind = "(".implode(', ', $data).")"; |
|
79 | + $valueBind = "(" . implode(', ', $data) . ")"; |
|
80 | 80 | $sql = $this->conn->prepare("INSERT INTO {$this->table} $parameters VALUES $valueBind"); |
81 | - for($i = 0; $i < count($params); $i++) { |
|
81 | + for ($i = 0; $i < count($params); $i++) { |
|
82 | 82 | $sql->bindParam($data[$i], $values[$i]); |
83 | 83 | } |
84 | 84 | return $sql->execute(); |
85 | - } catch(PDOException $exception) { |
|
85 | + } catch (PDOException $exception) { |
|
86 | 86 | echo $exception->getCode(); |
87 | 87 | } |
88 | 88 | } |