@@ -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 | [ |
@@ -11,28 +11,28 @@ |
||
11 | 11 | $params = explode(', ', $params); |
12 | 12 | $data = []; |
13 | 13 | $paramsCount = count($params); $dataCount = count($data); |
14 | - for($i = 0; $i < $paramsCount; $i++) { |
|
15 | - $data[$i] = ":".$params[$i][0].$params[$i][1].$params[$i][2].", "; |
|
14 | + for ($i = 0; $i < $paramsCount; $i++) { |
|
15 | + $data[$i] = ":" . $params[$i][0] . $params[$i][1] . $params[$i][2] . ", "; |
|
16 | 16 | } |
17 | 17 | $result = ''; |
18 | 18 | $final = array_map(null, $params, $data); |
19 | - foreach($final as $key => $vals) { |
|
20 | - foreach($vals as $chave => $val) { |
|
19 | + foreach ($final as $key => $vals) { |
|
20 | + foreach ($vals as $chave => $val) { |
|
21 | 21 | $result .= str_replace(':', ' = :', $val); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | $result = rtrim($result, ', '); |
25 | - $sql = $this->conn->prepare("UPDATE $table SET $result ". (isset($where) ? "WHERE ". $where : '')); |
|
26 | - for($i = 0; $i < $paramsCount; $i++) { |
|
27 | - $data[$i] = ":".$params[$i][0].$params[$i][1].$params[$i][2]; |
|
25 | + $sql = $this->conn->prepare("UPDATE $table SET $result " . (isset($where) ? "WHERE " . $where : '')); |
|
26 | + for ($i = 0; $i < $paramsCount; $i++) { |
|
27 | + $data[$i] = ":" . $params[$i][0] . $params[$i][1] . $params[$i][2]; |
|
28 | 28 | } |
29 | - for($i = 0; $i < $dataCount; $i++) { |
|
29 | + for ($i = 0; $i < $dataCount; $i++) { |
|
30 | 30 | $sql->bindParam($data[$i], $values[$i]); |
31 | 31 | } |
32 | - if($sql->execute()) { |
|
32 | + if ($sql->execute()) { |
|
33 | 33 | return true; |
34 | 34 | } else { |
35 | - echo "Erro:". $sql->errorInfo(); |
|
35 | + echo "Erro:" . $sql->errorInfo(); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -156,13 +156,17 @@ |
||
156 | 156 | switch (!is_object($this->data) && $count = count($this->data)) { |
157 | 157 | case (!isset($this->data[0]) && !empty($this->data)): |
158 | 158 | foreach ($this->excepts as $except) { |
159 | - if (isset($this->data[$except])) unset($this->data[$except]); |
|
159 | + if (isset($this->data[$except])) { |
|
160 | + unset($this->data[$except]); |
|
161 | + } |
|
160 | 162 | } |
161 | 163 | break; |
162 | 164 | case ($count >= 2 && isset($this->data[0])): |
163 | 165 | foreach ($this->excepts as $except) { |
164 | 166 | for ($i = 0; $i < $count; $i++) { |
165 | - if (isset($this->data[$i][$except])) unset($this->data[$i][$except]); |
|
167 | + if (isset($this->data[$i][$except])) { |
|
168 | + unset($this->data[$i][$except]); |
|
169 | + } |
|
166 | 170 | } |
167 | 171 | } |
168 | 172 | break; |