@@ -50,7 +50,7 @@ discard block |
||
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) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param array $elements Elements to update |
212 | 212 | * @param string $conditions Conditions for search |
213 | 213 | * |
214 | - * @return bool |
|
214 | + * @return boolean|null |
|
215 | 215 | */ |
216 | 216 | public function update($table, array $elements = [], $conditions = '') |
217 | 217 | { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param string $conditions Conditions to search |
228 | 228 | * @param array $params Params array |
229 | 229 | * |
230 | - * @return bool |
|
230 | + * @return boolean|null |
|
231 | 231 | */ |
232 | 232 | public function delete($table, $conditions, array $params = []) |
233 | 233 | { |
@@ -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 | |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function listFields($table) |
139 | 139 | { |
140 | - $sth = $this->conn->query('SELECT * FROM information_schema.columns WHERE table_name =\'' . $table . '\''); |
|
140 | + $sth = $this->conn->query('SELECT * FROM information_schema.columns WHERE table_name =\''.$table.'\''); |
|
141 | 141 | $result = []; |
142 | 142 | |
143 | 143 | foreach ($sth->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
144 | 144 | $result[] = [ |
145 | 145 | 'field' => $row['column_name'], |
146 | - 'type' => $row['data_type'] . (($max = $row['character_maximum_length']) ? '(' . $max . ')' : ''), |
|
146 | + 'type' => $row['data_type'].(($max = $row['character_maximum_length']) ? '('.$max.')' : ''), |
|
147 | 147 | 'null' => $row['is_nullable'], |
148 | 148 | 'default' => $row['column_default'] |
149 | 149 | ]; |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function insert($table, array $line = [], $multi = false) |
182 | 182 | { |
183 | - $fields = '"' . implode('", "', array_keys($multi ? $line[0] : $line)) . '"'; |
|
184 | - $values = ':' . implode(', :', array_keys($multi ? $line[0] : $line)); |
|
183 | + $fields = '"'.implode('", "', array_keys($multi ? $line[0] : $line)).'"'; |
|
184 | + $values = ':'.implode(', :', array_keys($multi ? $line[0] : $line)); |
|
185 | 185 | $rows = $multi ? $line : [$line]; |
186 | 186 | $id = null; |
187 | 187 | |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | |
191 | 191 | $dbh = null; |
192 | 192 | foreach ($rows AS $row) { |
193 | - $res = $this->conn->prepare('INSERT INTO ' . $table . ' (' . $fields . ') VALUES (' . $values . ');'); |
|
193 | + $res = $this->conn->prepare('INSERT INTO '.$table.' ('.$fields.') VALUES ('.$values.');'); |
|
194 | 194 | $dbh = $res->execute($row); |
195 | - die(var_dump($res->errorCode() . ': ' . print_r($res->errorInfo(), true))); |
|
195 | + die(var_dump($res->errorCode().': '.print_r($res->errorInfo(), true))); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $id = $dbh ? $this->conn->lastInsertId() : false; |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | $keys = []; |
265 | 265 | |
266 | 266 | foreach ($params AS $key => $val) { |
267 | - $keys[] = '"' . $key . '"=\'' . $val . '\''; |
|
267 | + $keys[] = '"'.$key.'"=\''.$val.'\''; |
|
268 | 268 | } |
269 | 269 | |
270 | - $sth = $this->conn->prepare('SELECT * FROM ' . $table . ' WHERE ' . implode(' AND ', $keys) . ' LIMIT 1;'); |
|
270 | + $sth = $this->conn->prepare('SELECT * FROM '.$table.' WHERE '.implode(' AND ', $keys).' LIMIT 1;'); |
|
271 | 271 | /** @noinspection PdoApiUsageInspection */ |
272 | 272 | $sth->execute(); |
273 | 273 |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function insert($table, array $line = [], $multi = false) |
183 | 183 | { |
184 | - $fields = '`' . implode('`, `', array_keys($multi ? $line[0] : $line)) . '`'; |
|
184 | + $fields = '`'.implode('`, `', array_keys($multi ? $line[0] : $line)).'`'; |
|
185 | 185 | |
186 | 186 | $values = ':'.implode(', :', array_keys($multi ? $line[0] : $line)); |
187 | 187 | $rows = $multi ? $line : [$line]; |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | $keys = []; |
291 | 291 | |
292 | 292 | foreach ($params AS $key => $val) { |
293 | - $keys[] = '`' . $key . '`="' . $val . '""'; |
|
293 | + $keys[] = '`'.$key.'`="'.$val.'""'; |
|
294 | 294 | } |
295 | 295 | |
296 | - $sth = $this->conn->prepare('SELECT * FROM ' . $table . ' WHERE ' . implode(' AND ', $keys) . ' LIMIT 1;'); |
|
296 | + $sth = $this->conn->prepare('SELECT * FROM '.$table.' WHERE '.implode(' AND ', $keys).' LIMIT 1;'); |
|
297 | 297 | /** @noinspection PdoApiUsageInspection */ |
298 | 298 | $sth->execute(); |
299 | 299 |