@@ -50,7 +50,7 @@ |
||
50 | 50 | * |
51 | 51 | * @param string $dbName Database name |
52 | 52 | * |
53 | - * @return boolean |
|
53 | + * @return boolean|null |
|
54 | 54 | * @throws \InvalidArgumentException |
55 | 55 | */ |
56 | 56 | public function switchDatabase($dbName) |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function listTables() |
82 | 82 | { |
83 | 83 | return $this->conn->query( |
84 | - 'SELECT table_name FROM information_schema.tables WHERE table_schema = \'' . $this->tableSchema . '\';' |
|
84 | + 'SELECT table_name FROM information_schema.tables WHERE table_schema = \''.$this->tableSchema.'\';' |
|
85 | 85 | )->fetchAll(\PDO::FETCH_COLUMN, 0); |
86 | 86 | } |
87 | 87 | |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function listFields($table) |
127 | 127 | { |
128 | - $sth = $this->conn->query('SELECT * FROM information_schema.columns WHERE table_name =\'' . $table . '\''); |
|
128 | + $sth = $this->conn->query('SELECT * FROM information_schema.columns WHERE table_name =\''.$table.'\''); |
|
129 | 129 | $result = []; |
130 | 130 | |
131 | 131 | foreach ($sth->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
132 | 132 | $result[] = [ |
133 | 133 | 'field' => $row['column_name'], |
134 | - 'type' => $row['data_type'] . (($max = $row['character_maximum_length']) ? '(' . $max . ')' : ''), |
|
134 | + 'type' => $row['data_type'].(($max = $row['character_maximum_length']) ? '('.$max.')' : ''), |
|
135 | 135 | 'null' => $row['is_nullable'], |
136 | 136 | 'default' => $row['column_default'] |
137 | 137 | ]; |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function insert($table, array $line = [], $multi = false) |
155 | 155 | { |
156 | - $fields = '"' . implode('", "', array_keys($multi ? $line[0] : $line)) . '"'; |
|
157 | - $values = ':' . implode(', :', array_keys($multi ? $line[0] : $line)); |
|
156 | + $fields = '"'.implode('", "', array_keys($multi ? $line[0] : $line)).'"'; |
|
157 | + $values = ':'.implode(', :', array_keys($multi ? $line[0] : $line)); |
|
158 | 158 | $rows = $multi ? $line : [$line]; |
159 | 159 | $id = null; |
160 | 160 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | |
164 | 164 | $dbh = null; |
165 | 165 | foreach ($rows AS $row) { |
166 | - $res = $this->conn->prepare('INSERT INTO ' . $table . ' (' . $fields . ') VALUES (' . $values . ');'); |
|
166 | + $res = $this->conn->prepare('INSERT INTO '.$table.' ('.$fields.') VALUES ('.$values.');'); |
|
167 | 167 | $dbh = $res->execute($row); |
168 | - die(var_dump($res->errorCode() . ': ' . print_r($res->errorInfo(), true))); |
|
168 | + die(var_dump($res->errorCode().': '.print_r($res->errorInfo(), true))); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $id = $dbh ? $this->conn->lastInsertId() : false; |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | $valStr = []; |
198 | 198 | |
199 | 199 | foreach ($keys as $key) { |
200 | - $valStr[] = '"' . $key . '" = :' . $key; |
|
200 | + $valStr[] = '"'.$key.'" = :'.$key; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $valStr = implode(',', $valStr); |
204 | 204 | |
205 | 205 | if ($conditions) { |
206 | - $conditions = 'WHERE ' . $conditions; |
|
206 | + $conditions = 'WHERE '.$conditions; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | return $this->conn->prepare("UPDATE {$table} SET {$valStr} {$conditions};")->execute($elements); |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | $keys = []; |
225 | 225 | |
226 | 226 | foreach ($params AS $key => $val) { |
227 | - $keys[] = '"' . $key . '"=\'' . $val . '\''; |
|
227 | + $keys[] = '"'.$key.'"=\''.$val.'\''; |
|
228 | 228 | } |
229 | 229 | |
230 | - $sth = $this->conn->prepare('SELECT * FROM ' . $table . ' WHERE ' . implode(' AND ', $keys) . ' LIMIT 1;'); |
|
230 | + $sth = $this->conn->prepare('SELECT * FROM '.$table.' WHERE '.implode(' AND ', $keys).' LIMIT 1;'); |
|
231 | 231 | /** @noinspection PdoApiUsageInspection */ |
232 | 232 | $sth->execute(); |
233 | 233 |