@@ -107,7 +107,7 @@ |
||
| 107 | 107 | public static function finder(IQuery $query = null, $single = false) |
| 108 | 108 | { |
| 109 | 109 | $query = ($query instanceof Query) ? $query : new Query((new ConnectionInjector)->build()); |
| 110 | - $query->table = static::$tableName . ' m'; |
|
| 110 | + $query->table = static::$tableName.' m'; |
|
| 111 | 111 | $query->objectName = get_called_class(); |
| 112 | 112 | $query->single = $single; |
| 113 | 113 | |
@@ -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; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function insert($table, array $line = [], $multi = false) |
| 202 | 202 | { |
| 203 | - $fields = '`' . implode('`, `', array_keys($multi ? $line[0] : $line)) . '`'; |
|
| 203 | + $fields = '`'.implode('`, `', array_keys($multi ? $line[0] : $line)).'`'; |
|
| 204 | 204 | |
| 205 | 205 | $values = ':'.implode(', :', array_keys($multi ? $line[0] : $line)); |
| 206 | 206 | $rows = $multi ? $line : [$line]; |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | $keys = []; |
| 310 | 310 | |
| 311 | 311 | foreach ($params AS $key => $val) { |
| 312 | - $keys[] = $table . '.' . $key . '=\'' . $val . '\''; |
|
| 312 | + $keys[] = $table.'.'.$key.'=\''.$val.'\''; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $sth = $this->conn->prepare('SELECT * FROM ' . $table . ' WHERE ' . implode(' AND ', $keys) . ' LIMIT 1;'); |
|
| 315 | + $sth = $this->conn->prepare('SELECT * FROM '.$table.' WHERE '.implode(' AND ', $keys).' LIMIT 1;'); |
|
| 316 | 316 | /** @noinspection PdoApiUsageInspection */ |
| 317 | 317 | $sth->execute(); |
| 318 | 318 | |
@@ -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); |
@@ -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,7 +190,7 @@ 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 | 195 | } |
| 196 | 196 | |