@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | return parent::connect(); |
| 83 | 83 | } catch (Exception $e) { |
| 84 | 84 | // throw a new exception to prevent leaking info from the stacktrace |
| 85 | - throw new Exception('Failed to connect to the database: ' . $e->getMessage(), $e->getCode()); |
|
| 85 | + throw new Exception('Failed to connect to the database: '.$e->getMessage(), $e->getCode()); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | // 0 is the method where we use `getCallerBacktrace` |
| 143 | 143 | // 1 is the target method which uses the method we want to log |
| 144 | 144 | if (isset($traces[1])) { |
| 145 | - return $traces[1]['file'] . ':' . $traces[1]['line']; |
|
| 145 | + return $traces[1]['file'].':'.$traces[1]['line']; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return ''; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $insertQb = $this->getQueryBuilder(); |
| 334 | 334 | $insertQb->insert($table) |
| 335 | 335 | ->values( |
| 336 | - array_map(function ($value) use ($insertQb) { |
|
| 336 | + array_map(function($value) use ($insertQb) { |
|
| 337 | 337 | return $insertQb->createNamedParameter($value, $this->getType($value)); |
| 338 | 338 | }, array_merge($keys, $values)) |
| 339 | 339 | ); |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.'); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $tableName = $this->tablePrefix . $tableName; |
|
| 390 | + $tableName = $this->tablePrefix.$tableName; |
|
| 391 | 391 | $this->lockedTable = $tableName; |
| 392 | 392 | $this->adapter->lockTable($tableName); |
| 393 | 393 | } |
@@ -409,11 +409,11 @@ discard block |
||
| 409 | 409 | * @return string |
| 410 | 410 | */ |
| 411 | 411 | public function getError() { |
| 412 | - $msg = $this->errorCode() . ': '; |
|
| 412 | + $msg = $this->errorCode().': '; |
|
| 413 | 413 | $errorInfo = $this->errorInfo(); |
| 414 | 414 | if (!empty($errorInfo)) { |
| 415 | - $msg .= 'SQLSTATE = '.$errorInfo[0] . ', '; |
|
| 416 | - $msg .= 'Driver Code = '.$errorInfo[1] . ', '; |
|
| 415 | + $msg .= 'SQLSTATE = '.$errorInfo[0].', '; |
|
| 416 | + $msg .= 'Driver Code = '.$errorInfo[1].', '; |
|
| 417 | 417 | $msg .= 'Driver Message = '.$errorInfo[2]; |
| 418 | 418 | } |
| 419 | 419 | return $msg; |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @throws Exception |
| 436 | 436 | */ |
| 437 | 437 | public function dropTable($table) { |
| 438 | - $table = $this->tablePrefix . trim($table); |
|
| 438 | + $table = $this->tablePrefix.trim($table); |
|
| 439 | 439 | $schema = $this->getSchemaManager(); |
| 440 | 440 | if ($schema->tablesExist([$table])) { |
| 441 | 441 | $schema->dropTable($table); |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @throws Exception |
| 452 | 452 | */ |
| 453 | 453 | public function tableExists($table) { |
| 454 | - $table = $this->tablePrefix . trim($table); |
|
| 454 | + $table = $this->tablePrefix.trim($table); |
|
| 455 | 455 | $schema = $this->getSchemaManager(); |
| 456 | 456 | return $schema->tablesExist([$table]); |
| 457 | 457 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function lockTable($tableName) { |
| 77 | 77 | $this->conn->beginTransaction(); |
| 78 | - $this->conn->executeUpdate('LOCK TABLE `' .$tableName . '` IN EXCLUSIVE MODE'); |
|
| 78 | + $this->conn->executeUpdate('LOCK TABLE `'.$tableName.'` IN EXCLUSIVE MODE'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | if (empty($compare)) { |
| 107 | 107 | $compare = array_keys($input); |
| 108 | 108 | } |
| 109 | - $query = 'INSERT INTO `' .$table . '` (`' |
|
| 110 | - . implode('`,`', array_keys($input)) . '`) SELECT ' |
|
| 109 | + $query = 'INSERT INTO `'.$table.'` (`' |
|
| 110 | + . implode('`,`', array_keys($input)).'`) SELECT ' |
|
| 111 | 111 | . str_repeat('?,', count($input) - 1).'? ' // Is there a prettier alternative? |
| 112 | - . 'FROM `' . $table . '` WHERE '; |
|
| 112 | + . 'FROM `'.$table.'` WHERE '; |
|
| 113 | 113 | |
| 114 | 114 | $inserts = array_values($input); |
| 115 | 115 | foreach ($compare as $key) { |
| 116 | - $query .= '`' . $key . '`'; |
|
| 116 | + $query .= '`'.$key.'`'; |
|
| 117 | 117 | if (is_null($input[$key])) { |
| 118 | 118 | $query .= ' IS NULL AND '; |
| 119 | 119 | } else { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | /** |
| 139 | 139 | * @throws \OCP\DB\Exception |
| 140 | 140 | */ |
| 141 | - public function insertIgnoreConflict(string $table,array $values) : int { |
|
| 141 | + public function insertIgnoreConflict(string $table, array $values) : int { |
|
| 142 | 142 | try { |
| 143 | 143 | $builder = $this->conn->getQueryBuilder(); |
| 144 | 144 | $builder->insert($table); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | 115 | protected function generateTemporaryTableName($name) { |
| 116 | - return $this->config->getSystemValue('dbtableprefix', 'oc_') . $name . '_' . $this->random->generate(13, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); |
|
| 116 | + return $this->config->getSystemValue('dbtableprefix', 'oc_').$name.'_'.$this->random->generate(13, ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $indexName = $index->getName(); |
| 165 | 165 | } else { |
| 166 | 166 | // avoid conflicts in index names |
| 167 | - $indexName = $this->config->getSystemValue('dbtableprefix', 'oc_') . $this->random->generate(13, ISecureRandom::CHAR_LOWER); |
|
| 167 | + $indexName = $this->config->getSystemValue('dbtableprefix', 'oc_').$this->random->generate(13, ISecureRandom::CHAR_LOWER); |
|
| 168 | 168 | } |
| 169 | 169 | $newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary()); |
| 170 | 170 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @throws Exception |
| 178 | 178 | */ |
| 179 | 179 | public function createSchema() { |
| 180 | - $this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) { |
|
| 180 | + $this->connection->getConfiguration()->setSchemaAssetsFilter(function($asset) { |
|
| 181 | 181 | /** @var string|AbstractAsset $asset */ |
| 182 | 182 | $filterExpression = $this->getFilterExpression(); |
| 183 | 183 | if ($asset instanceof AbstractAsset) { |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) { |
|
| 209 | + $this->connection->getConfiguration()->setSchemaAssetsFilter(function($asset) { |
|
| 210 | 210 | /** @var string|AbstractAsset $asset */ |
| 211 | 211 | $filterExpression = $this->getFilterExpression(); |
| 212 | 212 | if ($asset instanceof AbstractAsset) { |
@@ -268,15 +268,15 @@ discard block |
||
| 268 | 268 | $quotedSource = $this->connection->quoteIdentifier($sourceName); |
| 269 | 269 | $quotedTarget = $this->connection->quoteIdentifier($targetName); |
| 270 | 270 | |
| 271 | - $this->connection->exec('CREATE TABLE ' . $quotedTarget . ' (LIKE ' . $quotedSource . ')'); |
|
| 272 | - $this->connection->exec('INSERT INTO ' . $quotedTarget . ' SELECT * FROM ' . $quotedSource); |
|
| 271 | + $this->connection->exec('CREATE TABLE '.$quotedTarget.' (LIKE '.$quotedSource.')'); |
|
| 272 | + $this->connection->exec('INSERT INTO '.$quotedTarget.' SELECT * FROM '.$quotedSource); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * @param string $name |
| 277 | 277 | */ |
| 278 | 278 | protected function dropTable($name) { |
| 279 | - $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($name)); |
|
| 279 | + $this->connection->exec('DROP TABLE '.$this->connection->quoteIdentifier($name)); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -284,14 +284,14 @@ discard block |
||
| 284 | 284 | * @return string |
| 285 | 285 | */ |
| 286 | 286 | protected function convertStatementToScript($statement) { |
| 287 | - $script = $statement . ';'; |
|
| 287 | + $script = $statement.';'; |
|
| 288 | 288 | $script .= PHP_EOL; |
| 289 | 289 | $script .= PHP_EOL; |
| 290 | 290 | return $script; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | protected function getFilterExpression() { |
| 294 | - return '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; |
|
| 294 | + return '/^'.preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')).'/'; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | protected function emit($sql, $step, $max) { |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | |
| 89 | 89 | public function lastInsertId(string $table): int { |
| 90 | 90 | try { |
| 91 | - return (int)$this->inner->lastInsertId($table); |
|
| 91 | + return (int) $this->inner->lastInsertId($table); |
|
| 92 | 92 | } catch (Exception $e) { |
| 93 | 93 | throw DbalException::wrap($e); |
| 94 | 94 | } |