@@ -69,29 +69,29 @@ |
||
| 69 | 69 | |
| 70 | 70 | public function submit(Form $form, ArrayHash $values) |
| 71 | 71 | { |
| 72 | - $values = (array)$values; |
|
| 73 | - $keys = array_map(function ($key) { |
|
| 74 | - return '`' . $key . '`'; |
|
| 72 | + $values = (array) $values; |
|
| 73 | + $keys = array_map(function($key) { |
|
| 74 | + return '`'.$key.'`'; |
|
| 75 | 75 | }, array_keys($values)); |
| 76 | - $vals = array_map(function ($key) { |
|
| 77 | - return ':' . $key; |
|
| 76 | + $vals = array_map(function($key) { |
|
| 77 | + return ':'.$key; |
|
| 78 | 78 | }, array_keys($values)); |
| 79 | 79 | if ($this->item) { |
| 80 | - $query = 'UPDATE `' . $this->table . '` SET '; |
|
| 80 | + $query = 'UPDATE `'.$this->table.'` SET '; |
|
| 81 | 81 | $set = []; |
| 82 | 82 | foreach ($values as $key => $value) { |
| 83 | - $set[] = '`' . $key . '` = :' . $key; |
|
| 83 | + $set[] = '`'.$key.'` = :'.$key; |
|
| 84 | 84 | } |
| 85 | 85 | $query .= implode(', ', $set); |
| 86 | 86 | $primaryColumns = $this->dataManager->getPrimaryColumns($this->type, $this->table); |
| 87 | - $query .= ' WHERE md5(concat(' . implode(', "|", ', $primaryColumns) . ')) = "' . $this->item . '"'; |
|
| 87 | + $query .= ' WHERE md5(concat('.implode(', "|", ', $primaryColumns).')) = "'.$this->item.'"'; |
|
| 88 | 88 | } else { |
| 89 | - $query = sprintf('INSERT INTO `' . $this->table . '` %s VALUES %s', '(' . implode(', ', $keys) . ')', '(' . implode(', ', $vals) . ')'); |
|
| 89 | + $query = sprintf('INSERT INTO `'.$this->table.'` %s VALUES %s', '('.implode(', ', $keys).')', '('.implode(', ', $vals).')'); |
|
| 90 | 90 | } |
| 91 | 91 | $statement = $this->pdo->prepare($query); |
| 92 | 92 | foreach ($values as $key => $value) { |
| 93 | 93 | $value = $value === '' && $this->columns[$key]['Null'] ? null : $value; |
| 94 | - $statement->bindValue(':' . $key, $value); |
|
| 94 | + $statement->bindValue(':'.$key, $value); |
|
| 95 | 95 | } |
| 96 | 96 | $ret = $statement->execute(); |
| 97 | 97 | if (!$ret) { |
@@ -47,14 +47,14 @@ |
||
| 47 | 47 | public function submit(Form $form, ArrayHash $values) |
| 48 | 48 | { |
| 49 | 49 | if ($this->database) { |
| 50 | - $query = 'ALTER DATABASE ' . $this->database; |
|
| 50 | + $query = 'ALTER DATABASE '.$this->database; |
|
| 51 | 51 | } else { |
| 52 | - $query = 'CREATE DATABASE ' . $values['name']; |
|
| 52 | + $query = 'CREATE DATABASE '.$values['name']; |
|
| 53 | 53 | } |
| 54 | 54 | if ($values['charset']) { |
| 55 | - $query .= ' CHARACTER SET ' . $values['charset']; |
|
| 55 | + $query .= ' CHARACTER SET '.$values['charset']; |
|
| 56 | 56 | if ($values['collation']) { |
| 57 | - $query .= ' COLLATE ' . $values['collation']; |
|
| 57 | + $query .= ' COLLATE '.$values['collation']; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | public function itemsCount($type, $table, array $filter = []) |
| 104 | 104 | { |
| 105 | - $query = 'SELECT count(*) FROM `' . $table . '`' . $this->createWhere($filter); |
|
| 105 | + $query = 'SELECT count(*) FROM `'.$table.'`'.$this->createWhere($filter); |
|
| 106 | 106 | return $this->connection->query($query)->fetch(PDO::FETCH_COLUMN); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function items($type, $table, $page, $onPage, array $filter = [], array $sorting = []) |
| 110 | 110 | { |
| 111 | 111 | $primaryColumns = $this->getPrimaryColumns($type, $table); |
| 112 | - $query = 'SELECT * FROM `' . $table . '`'; |
|
| 112 | + $query = 'SELECT * FROM `'.$table.'`'; |
|
| 113 | 113 | $query .= $this->createWhere($filter); |
| 114 | 114 | $query .= $this->createOrderBy($sorting); |
| 115 | - $query .= ' LIMIT ' . (($page - 1) * $onPage) . ', ' . $onPage; |
|
| 115 | + $query .= ' LIMIT '.(($page - 1) * $onPage).', '.$onPage; |
|
| 116 | 116 | $items = []; |
| 117 | 117 | foreach ($this->connection->query($query)->fetchAll(PDO::FETCH_ASSOC) as $item) { |
| 118 | 118 | $pk = []; |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | foreach ($filterPart as $key => $filterSettings) { |
| 154 | 154 | foreach ($filterSettings as $operator => $value) { |
| 155 | 155 | if (!isset($operatorsMap[$operator])) { |
| 156 | - throw new OperatorNotSupportedException('Operator "' . $operator . '" is not supported.'); |
|
| 156 | + throw new OperatorNotSupportedException('Operator "'.$operator.'" is not supported.'); |
|
| 157 | 157 | } |
| 158 | - $whereParts[] = "`$key`" . sprintf($operatorsMap[$operator], $value); |
|
| 158 | + $whereParts[] = "`$key`".sprintf($operatorsMap[$operator], $value); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | public function loadItem($type, $table, $item) |
| 184 | 184 | { |
| 185 | 185 | $primaryColumns = $this->getPrimaryColumns($type, $table); |
| 186 | - $query = 'SELECT * FROM `' . $table . '` WHERE md5(concat(' . implode(', "|", ', $primaryColumns) . ')) = "' . $item . '"'; |
|
| 186 | + $query = 'SELECT * FROM `'.$table.'` WHERE md5(concat('.implode(', "|", ', $primaryColumns).')) = "'.$item.'"'; |
|
| 187 | 187 | return $this->connection->query($query)->fetch(PDO::FETCH_ASSOC); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -191,32 +191,32 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $primaryColumns = $this->getPrimaryColumns($type, $table); |
| 193 | 193 | |
| 194 | - $query = 'DELETE FROM `' . $table . '` WHERE md5(concat(' . implode(', "|", ', $primaryColumns) . ')) = "' . $item . '"'; |
|
| 194 | + $query = 'DELETE FROM `'.$table.'` WHERE md5(concat('.implode(', "|", ', $primaryColumns).')) = "'.$item.'"'; |
|
| 195 | 195 | return $this->connection->query($query); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | public function deleteTable($type, $table) |
| 199 | 199 | { |
| 200 | 200 | if ($type === MySqlDriver::TYPE_TABLE) { |
| 201 | - $query = 'DROP TABLE `' . $table . '`'; |
|
| 201 | + $query = 'DROP TABLE `'.$table.'`'; |
|
| 202 | 202 | } elseif ($type === MySqlDriver::TYPE_VIEW) { |
| 203 | - $query = 'DROP VIEW `' . $table . '`'; |
|
| 203 | + $query = 'DROP VIEW `'.$table.'`'; |
|
| 204 | 204 | } else { |
| 205 | - throw new InvalidArgumentException('Type "' . $type . '" is not supported'); |
|
| 205 | + throw new InvalidArgumentException('Type "'.$type.'" is not supported'); |
|
| 206 | 206 | } |
| 207 | 207 | return $this->connection->query($query); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | public function deleteDatabase($database) |
| 211 | 211 | { |
| 212 | - $query = 'DROP DATABASE `' . $database . '`'; |
|
| 212 | + $query = 'DROP DATABASE `'.$database.'`'; |
|
| 213 | 213 | return $this->connection->query($query); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | public function selectDatabase($database) |
| 217 | 217 | { |
| 218 | 218 | $this->database = $database; |
| 219 | - $this->connection->query('USE `' . $database . '`'); |
|
| 219 | + $this->connection->query('USE `'.$database.'`'); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | public function getPrimaryColumns($type, $table) |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | public function getColumns($type, $table) |
| 239 | 239 | { |
| 240 | 240 | if ($this->columns === null) { |
| 241 | - $columns = $this->connection->query('SHOW FULL COLUMNS FROM `' . $table .'`')->fetchAll(PDO::FETCH_ASSOC); |
|
| 241 | + $columns = $this->connection->query('SHOW FULL COLUMNS FROM `'.$table.'`')->fetchAll(PDO::FETCH_ASSOC); |
|
| 242 | 242 | $keys = []; |
| 243 | 243 | foreach ($this->connection->query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '{$this->database}' AND TABLE_NAME = '$table'")->fetchAll(PDO::FETCH_ASSOC) as $key) { |
| 244 | 244 | $keys[$key['COLUMN_NAME']] = $key; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | public function execute($commands) |
| 256 | 256 | { |
| 257 | - $queries = array_filter(array_map('trim', explode(';', $commands)), function ($query) { |
|
| 257 | + $queries = array_filter(array_map('trim', explode(';', $commands)), function($query) { |
|
| 258 | 258 | return $query; |
| 259 | 259 | }); |
| 260 | 260 | $results = []; |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | if (strpos($credentials['server'], ':') !== false) { |
| 43 | 43 | list($host, $port) = explode(':', $credentials['server'], 2); |
| 44 | 44 | } |
| 45 | - $dsn = 'mysql:;host=' . $host . ';port=' . $port . ';charset=utf8'; |
|
| 45 | + $dsn = 'mysql:;host='.$host.';port='.$port.';charset=utf8'; |
|
| 46 | 46 | try { |
| 47 | 47 | $this->connection = new PDO($dsn, $credentials['user'], $credentials['password']); |
| 48 | 48 | } catch (PDOException $e) { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | public function submit(Form $form, ArrayHash $values) |
| 30 | 30 | { |
| 31 | 31 | if ($this->connection->hlen($values['key']) > 0) { |
| 32 | - $form->addError('Key "' . $values['key'] . '" already exists'); |
|
| 32 | + $form->addError('Key "'.$values['key'].'" already exists'); |
|
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | $this->connection->hset($values['key'], $values['field'], $values['value']); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | public function submit(Form $form, ArrayHash $values) |
| 33 | 33 | { |
| 34 | 34 | if (!$this->connection->rename($this->key, $values['new_key'])) { |
| 35 | - $form->addError('Key "' . $this->key . '" doesn\'t exist'); |
|
| 35 | + $form->addError('Key "'.$this->key.'" doesn\'t exist'); |
|
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | 'expires' => null, |
| 298 | 298 | 'avg_ttl' => null, |
| 299 | 299 | ]; |
| 300 | - if (isset($keyspace['db' . $db])) { |
|
| 301 | - $dbKeyspace = explode(',', $keyspace['db' . $db]); |
|
| 300 | + if (isset($keyspace['db'.$db])) { |
|
| 301 | + $dbKeyspace = explode(',', $keyspace['db'.$db]); |
|
| 302 | 302 | $info['keys'] = explode('=', $dbKeyspace[0])[1]; |
| 303 | 303 | $info['expires'] = explode('=', $dbKeyspace[1])[1]; |
| 304 | 304 | $info['avg_ttl'] = explode('=', $dbKeyspace[2])[1]; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | public function execute($commands) |
| 310 | 310 | { |
| 311 | - $listOfCommands = array_filter(array_map('trim', explode("\n", $commands)), function ($command) { |
|
| 311 | + $listOfCommands = array_filter(array_map('trim', explode("\n", $commands)), function($command) { |
|
| 312 | 312 | return $command; |
| 313 | 313 | }); |
| 314 | 314 | |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | |
| 70 | 70 | $this->template->steps = $steps; |
| 71 | 71 | $this->template->paginator = $paginator; |
| 72 | - $this->template->setFile(dirname(__FILE__) . '/' . $this->paginatorTemplate . '.latte'); |
|
| 72 | + $this->template->setFile(dirname(__FILE__).'/'.$this->paginatorTemplate.'.latte'); |
|
| 73 | 73 | $this->template->render(); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $this->template->driver = $this->driver; |
| 30 | 30 | $this->template->actualDatabase = $this->database; |
| 31 | - $this->template->setFile(__DIR__ . '/default.latte'); |
|
| 31 | + $this->template->setFile(__DIR__.'/default.latte'); |
|
| 32 | 32 | $this->template->render(); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | sort($databases); |
| 39 | 39 | $form = new Form(); |
| 40 | 40 | $form->setRenderer(new BootstrapVerticalRenderer()); |
| 41 | - $form->addSelect('database', $this->translator->translate($this->driver->type() . '.database_select_control.database.label'), array_combine($databases, $databases)) |
|
| 42 | - ->setPrompt($this->translator->translate($this->driver->type() . '.database_select_control.database.prompt')) |
|
| 43 | - ->setAttribute('onchange', 'window.location = \'' . $this->presenter->link('Table:default', $this->driver->type()) . '&database=\' + this.value') |
|
| 41 | + $form->addSelect('database', $this->translator->translate($this->driver->type().'.database_select_control.database.label'), array_combine($databases, $databases)) |
|
| 42 | + ->setPrompt($this->translator->translate($this->driver->type().'.database_select_control.database.prompt')) |
|
| 43 | + ->setAttribute('onchange', 'window.location = \''.$this->presenter->link('Table:default', $this->driver->type()).'&database=\' + this.value') |
|
| 44 | 44 | ->setDefaultValue($this->database); |
| 45 | 45 | return $form; |
| 46 | 46 | } |