@@ -257,7 +257,7 @@ |
||
257 | 257 | * @param \Closure $event ['Object', 'method'] or callable |
258 | 258 | * @param int|null $prior priority |
259 | 259 | * |
260 | - * @return boolean|null |
|
260 | + * @return boolean |
|
261 | 261 | * @throws Exception |
262 | 262 | */ |
263 | 263 | protected function addListener($listener, $event, $prior = null) |
@@ -53,7 +53,7 @@ |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * @return bool|int |
|
56 | + * @return integer |
|
57 | 57 | * @throws Exception |
58 | 58 | */ |
59 | 59 | public function getID() |
@@ -155,7 +155,7 @@ |
||
155 | 155 | $query->distinct = true; |
156 | 156 | $query->select = $this->db->getDriverType() == 'pgsql' ? '"role" AS "name"' : '`role` AS `name`'; |
157 | 157 | $query->table = $this->db->getDriverType() == 'pgsql' ? '"rbac_user"' : '`rbac_user`'; |
158 | - $query->addWhere(($this->db->getDriverType() == 'pgsql' ? '"user"=' : '`user`=') . $userId); |
|
158 | + $query->addWhere(($this->db->getDriverType() == 'pgsql' ? '"user"=' : '`user`=').$userId); |
|
159 | 159 | $query->single = false; |
160 | 160 | |
161 | 161 | return $query->run(\PDO::FETCH_ASSOC); |
@@ -165,17 +165,17 @@ |
||
165 | 165 | |
166 | 166 | if ($this->db->getDriverType() === 'pgsql') { |
167 | 167 | if ($this->limit !== -1) { |
168 | - $query .= ' LIMIT ' . $this->limit . ' '; |
|
168 | + $query .= ' LIMIT '.$this->limit.' '; |
|
169 | 169 | } |
170 | 170 | if ($this->offset !== -1) { |
171 | - $query .= ' OFFSET ' . $this->offset . ' '; |
|
171 | + $query .= ' OFFSET '.$this->offset.' '; |
|
172 | 172 | } |
173 | 173 | } else { |
174 | 174 | if ($this->limit !== -1) { |
175 | 175 | $query .= ' LIMIT '; |
176 | 176 | |
177 | 177 | if ($this->offset !== -1) { |
178 | - $query .= $this->offset . ','; |
|
178 | + $query .= $this->offset.','; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $query .= $this->limit; |
@@ -81,6 +81,7 @@ |
||
81 | 81 | /** |
82 | 82 | * @inheritdoc |
83 | 83 | * @throws \Micro\Base\Exception |
84 | + * @param string $name |
|
84 | 85 | */ |
85 | 86 | protected function getElement($name) |
86 | 87 | { |
@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | } catch (\PDOException $e) { |
44 | 44 | if (!array_key_exists('ignoreFail', $config) || !$config['ignoreFail']) { |
45 | - throw new Exception('Connect to DB failed: ' . $e->getMessage()); |
|
45 | + throw new Exception('Connect to DB failed: '.$e->getMessage()); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function setDriver($dsn, array $config = [], array $options = []) |
55 | 55 | { |
56 | - $class = '\Micro\Db\Drivers\\' . ucfirst(substr($dsn, 0, strpos($dsn, ':'))) . 'Driver'; |
|
56 | + $class = '\Micro\Db\Drivers\\'.ucfirst(substr($dsn, 0, strpos($dsn, ':'))).'Driver'; |
|
57 | 57 | |
58 | 58 | if (!class_exists($class)) { |
59 | - throw new Exception('DB driver `' . $class . '` not supported'); |
|
59 | + throw new Exception('DB driver `'.$class.'` not supported'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | unset($this->driver); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function __call($name, array $arguments = []) |
79 | 79 | { |
80 | 80 | if (!method_exists($this->driver, $name)) { |
81 | - throw new \BadMethodCallException('Method `' . $name . '` not found in connection driver `' . get_class($this->driver) . '`'); |
|
81 | + throw new \BadMethodCallException('Method `'.$name.'` not found in connection driver `'.get_class($this->driver).'`'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return call_user_func_array([$this->driver, $name], $arguments); |
@@ -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 |
@@ -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,7 +163,7 @@ 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 | 168 | } |
169 | 169 | |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | $valStr = []; |
197 | 197 | |
198 | 198 | foreach ($keys as $key) { |
199 | - $valStr[] = '"' . $key . '" = :' . $key; |
|
199 | + $valStr[] = '"'.$key.'" = :'.$key; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | $valStr = implode(',', $valStr); |
203 | 203 | |
204 | 204 | if ($conditions) { |
205 | - $conditions = 'WHERE ' . $conditions; |
|
205 | + $conditions = 'WHERE '.$conditions; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return $this->conn->prepare("UPDATE {$table} SET {$valStr} {$conditions};")->execute($elements); |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | $keys = []; |
224 | 224 | |
225 | 225 | foreach ($params AS $key => $val) { |
226 | - $keys[] = '"' . $key . '"=\'' . $val . '\''; |
|
226 | + $keys[] = '"'.$key.'"=\''.$val.'\''; |
|
227 | 227 | } |
228 | 228 | |
229 | - $sth = $this->conn->prepare('SELECT * FROM ' . $table . ' WHERE ' . implode(' AND ', $keys) . ' LIMIT 1;'); |
|
229 | + $sth = $this->conn->prepare('SELECT * FROM '.$table.' WHERE '.implode(' AND ', $keys).' LIMIT 1;'); |
|
230 | 230 | /** @noinspection PdoApiUsageInspection */ |
231 | 231 | $sth->execute(); |
232 | 232 |