@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function seek($row) |
| 44 | 44 | { |
| 45 | 45 | $this->handle->reset(); |
| 46 | - $i=0; |
|
| 46 | + $i = 0; |
|
| 47 | 47 | while ($i < $row && $row = @$this->handle->fetchArray()) { |
| 48 | 48 | $i++; |
| 49 | 49 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function numRecords() |
| 57 | 57 | { |
| 58 | - $c=0; |
|
| 58 | + $c = 0; |
|
| 59 | 59 | while ($this->handle->fetchArray()) { |
| 60 | 60 | $c++; |
| 61 | 61 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | self::create_db_dir($databaseConfig['path']); |
| 27 | 27 | self::secure_db_dir($databaseConfig['path']); |
| 28 | 28 | } |
| 29 | - $file = $databaseConfig['path'] . '/' . $databaseConfig['database']; |
|
| 29 | + $file = $databaseConfig['path'].'/'.$databaseConfig['database']; |
|
| 30 | 30 | $conn = null; |
| 31 | 31 | |
| 32 | 32 | switch ($databaseConfig['type']) { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public static function secure_db_dir($path) |
| 214 | 214 | { |
| 215 | - return (is_writeable($path)) ? file_put_contents($path . '/.htaccess', 'deny from all') : false; |
|
| 215 | + return (is_writeable($path)) ? file_put_contents($path.'/.htaccess', 'deny from all') : false; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | public function requireDatabaseAlterPermissions($databaseConfig) |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // If using file based database ensure any existing file is removed |
| 46 | 46 | $parameters = $this->database->getParameters(); |
| 47 | - $fullpath = $parameters['path'] . '/' . $name; |
|
| 47 | + $fullpath = $parameters['path'].'/'.$name; |
|
| 48 | 48 | if (is_writable($fullpath)) { |
| 49 | 49 | unlink($fullpath); |
| 50 | 50 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | public function alterField($tableName, $fieldName, $fieldSpec) |
| 243 | 243 | { |
| 244 | 244 | $oldFieldList = $this->fieldList($tableName); |
| 245 | - $fieldNameList = '"' . implode('","', array_keys($oldFieldList)) . '"'; |
|
| 245 | + $fieldNameList = '"'.implode('","', array_keys($oldFieldList)).'"'; |
|
| 246 | 246 | |
| 247 | 247 | if (!empty($_REQUEST['avoidConflict']) && Director::isDev()) { |
| 248 | 248 | $fieldSpec = preg_replace('/\snot null\s/i', ' NOT NULL ON CONFLICT REPLACE ', $fieldSpec); |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | // Update field spec |
| 257 | 257 | $newColsSpec = array(); |
| 258 | 258 | foreach ($oldFieldList as $name => $oldSpec) { |
| 259 | - $newColsSpec[] = "\"$name\" " . ($name == $fieldName ? $fieldSpec : $oldSpec); |
|
| 259 | + $newColsSpec[] = "\"$name\" ".($name == $fieldName ? $fieldSpec : $oldSpec); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $queries = array( |
| 263 | 263 | "BEGIN TRANSACTION", |
| 264 | - "CREATE TABLE \"{$tableName}_alterfield_{$fieldName}\"(" . implode(',', $newColsSpec) . ")", |
|
| 264 | + "CREATE TABLE \"{$tableName}_alterfield_{$fieldName}\"(".implode(',', $newColsSpec).")", |
|
| 265 | 265 | "INSERT INTO \"{$tableName}_alterfield_{$fieldName}\" SELECT {$fieldNameList} FROM \"$tableName\"", |
| 266 | 266 | "DROP TABLE \"$tableName\"", |
| 267 | 267 | "ALTER TABLE \"{$tableName}_alterfield_{$fieldName}\" RENAME TO \"$tableName\"", |
@@ -295,15 +295,15 @@ discard block |
||
| 295 | 295 | $oldCols = array(); |
| 296 | 296 | $newColsSpec = array(); |
| 297 | 297 | foreach ($oldFieldList as $name => $spec) { |
| 298 | - $oldCols[] = "\"$name\"" . (($name == $oldName) ? " AS $newName" : ''); |
|
| 299 | - $newColsSpec[] = "\"" . (($name == $oldName) ? $newName : $name) . "\" $spec"; |
|
| 298 | + $oldCols[] = "\"$name\"".(($name == $oldName) ? " AS $newName" : ''); |
|
| 299 | + $newColsSpec[] = "\"".(($name == $oldName) ? $newName : $name)."\" $spec"; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // SQLite doesn't support direct renames through ALTER TABLE |
| 303 | 303 | $queries = array( |
| 304 | 304 | "BEGIN TRANSACTION", |
| 305 | - "CREATE TABLE \"{$tableName}_renamefield_{$oldName}\" (" . implode(',', $newColsSpec) . ")", |
|
| 306 | - "INSERT INTO \"{$tableName}_renamefield_{$oldName}\" SELECT " . implode(',', $oldCols) . " FROM \"$tableName\"", |
|
| 305 | + "CREATE TABLE \"{$tableName}_renamefield_{$oldName}\" (".implode(',', $newColsSpec).")", |
|
| 306 | + "INSERT INTO \"{$tableName}_renamefield_{$oldName}\" SELECT ".implode(',', $oldCols)." FROM \"$tableName\"", |
|
| 307 | 307 | "DROP TABLE \"$tableName\"", |
| 308 | 308 | "ALTER TABLE \"{$tableName}_renamefield_{$oldName}\" RENAME TO \"$tableName\"", |
| 309 | 309 | "COMMIT" |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | public function boolean($values) |
| 457 | 457 | { |
| 458 | - $default = empty($values['default']) ? 0 : (int)$values['default']; |
|
| 458 | + $default = empty($values['default']) ? 0 : (int) $values['default']; |
|
| 459 | 459 | return "BOOL NOT NULL DEFAULT $default"; |
| 460 | 460 | } |
| 461 | 461 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | */ |
| 500 | 500 | public function enum($values) |
| 501 | 501 | { |
| 502 | - $tablefield = $values['table'] . '.' . $values['name']; |
|
| 502 | + $tablefield = $values['table'].'.'.$values['name']; |
|
| 503 | 503 | $enumValues = implode(',', $values['enums']); |
| 504 | 504 | |
| 505 | 505 | // Ensure the cache table exists |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | */ |
| 570 | 570 | public function int($values, $asDbValue = false) |
| 571 | 571 | { |
| 572 | - return "INTEGER({$values['precision']}) " . strtoupper($values['null']) . " DEFAULT " . (int)$values['default']; |
|
| 572 | + return "INTEGER({$values['precision']}) ".strtoupper($values['null'])." DEFAULT ".(int) $values['default']; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | public function hasTable($tableName) |
| 646 | 646 | { |
| 647 | - return (bool)$this->preparedQuery( |
|
| 647 | + return (bool) $this->preparedQuery( |
|
| 648 | 648 | 'SELECT name FROM sqlite_master WHERE type = ? AND name = ?', |
| 649 | 649 | array('table', $tableName) |
| 650 | 650 | )->first(); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $rowParts[] = implode(', ', $parts); |
| 50 | 50 | } |
| 51 | 51 | $columnSQL = implode(', ', $columns); |
| 52 | - $sql = "INSERT INTO {$into}{$nl}($columnSQL){$nl}SELECT " . implode("{$nl}UNION ALL SELECT ", $rowParts); |
|
| 52 | + $sql = "INSERT INTO {$into}{$nl}($columnSQL){$nl}SELECT ".implode("{$nl}UNION ALL SELECT ", $rowParts); |
|
| 53 | 53 | |
| 54 | 54 | return $sql; |
| 55 | 55 | } |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // For literal values return this as the limit SQL |
| 75 | - if (! is_array($limit)) { |
|
| 75 | + if (!is_array($limit)) { |
|
| 76 | 76 | return "{$nl}LIMIT $limit"; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Assert that the array version provides the 'limit' key |
| 80 | - if (! array_key_exists('limit', $limit) || ($limit['limit'] !== null && ! is_numeric($limit['limit']))) { |
|
| 80 | + if (!array_key_exists('limit', $limit) || ($limit['limit'] !== null && !is_numeric($limit['limit']))) { |
|
| 81 | 81 | throw new InvalidArgumentException( |
| 82 | - 'SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: '. var_export($limit, true) |
|
| 82 | + 'SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: '.var_export($limit, true) |
|
| 83 | 83 | ); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | // Ensure database name is set |
| 112 | 112 | if (empty($parameters['database'])) { |
| 113 | - $parameters['database'] = 'database' . self::database_extension(); |
|
| 113 | + $parameters['database'] = 'database'.self::database_extension(); |
|
| 114 | 114 | } |
| 115 | 115 | $dbName = $parameters['database']; |
| 116 | 116 | if (!self::is_valid_database_name($dbName)) { |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | // Ensure path is given |
| 128 | 128 | if (empty($parameters['path'])) { |
| 129 | - $parameters['path'] = ASSETS_PATH . '/.sqlitedb'; |
|
| 129 | + $parameters['path'] = ASSETS_PATH.'/.sqlitedb'; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | //assumes that the path to dbname will always be provided: |
| 133 | - $file = $parameters['path'] . '/' . $dbName; |
|
| 133 | + $file = $parameters['path'].'/'.$dbName; |
|
| 134 | 134 | if (!file_exists($parameters['path'])) { |
| 135 | 135 | SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']); |
| 136 | 136 | SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']); |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | $extraFilters[$fileClass] .= " AND ShowInSearch <> 0"; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $limit = $start . ", " . (int) $pageLength; |
|
| 294 | + $limit = $start.", ".(int) $pageLength; |
|
| 295 | 295 | |
| 296 | 296 | $notMatch = $invertedMatch ? "NOT " : ""; |
| 297 | 297 | if ($keywords) { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $queries = array(); |
| 317 | 317 | foreach ($classesToSearch as $class) { |
| 318 | 318 | $queries[$class] = DataList::create($class) |
| 319 | - ->where($notMatch . $match[$class] . $extraFilters[$class]) |
|
| 319 | + ->where($notMatch.$match[$class].$extraFilters[$class]) |
|
| 320 | 320 | ->dataQuery() |
| 321 | 321 | ->query(); |
| 322 | 322 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | "\"Created\"", |
| 335 | 335 | "NULL AS \"Name\"", |
| 336 | 336 | "\"CanViewType\"", |
| 337 | - $relevance[$pageClass] . " AS Relevance" |
|
| 337 | + $relevance[$pageClass]." AS Relevance" |
|
| 338 | 338 | ), |
| 339 | 339 | $fileClass => array( |
| 340 | 340 | "\"ClassName\"", |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | "\"Created\"", |
| 348 | 348 | "\"Name\"", |
| 349 | 349 | "NULL AS \"CanViewType\"", |
| 350 | - $relevance[$fileClass] . " AS Relevance" |
|
| 350 | + $relevance[$fileClass]." AS Relevance" |
|
| 351 | 351 | ) |
| 352 | 352 | ); |
| 353 | 353 | |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $totalCount += $query->unlimitedRowCount(); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $fullQuery = implode(" UNION ", $querySQLs) . " ORDER BY $sortBy LIMIT $limit"; |
|
| 381 | + $fullQuery = implode(" UNION ", $querySQLs)." ORDER BY $sortBy LIMIT $limit"; |
|
| 382 | 382 | // Get records |
| 383 | 383 | $records = $this->preparedQuery($fullQuery, $queryParameters); |
| 384 | 384 | |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $comp = 'LIKE'; |
| 466 | 466 | } |
| 467 | 467 | if ($negate) { |
| 468 | - $comp = 'NOT ' . $comp; |
|
| 468 | + $comp = 'NOT '.$comp; |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | preg_match_all('/%(.)/', $format, $matches); |
| 482 | 482 | foreach ($matches[1] as $match) { |
| 483 | 483 | if (array_search($match, array('Y', 'm', 'd', 'H', 'i', 's', 'U')) === false) { |
| 484 | - user_error('formattedDatetimeClause(): unsupported format character %' . $match, E_USER_WARNING); |
|
| 484 | + user_error('formattedDatetimeClause(): unsupported format character %'.$match, E_USER_WARNING); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | $date = "'$date'"; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - $modifier = empty($modifiers) ? '' : ", '" . implode("', '", $modifiers) . "'"; |
|
| 509 | + $modifier = empty($modifiers) ? '' : ", '".implode("', '", $modifiers)."'"; |
|
| 510 | 510 | return "strftime('$format', $date$modifier)"; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | $date = "'$date'"; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $modifier = empty($modifiers) ? '' : ", '" . implode("', '", $modifiers) . "'"; |
|
| 526 | + $modifier = empty($modifiers) ? '' : ", '".implode("', '", $modifiers)."'"; |
|
| 527 | 527 | return "datetime($date$modifier, '$interval')"; |
| 528 | 528 | } |
| 529 | 529 | |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | $date2 = "'$date2'"; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - $modifier1 = empty($modifiers1) ? '' : ", '" . implode("', '", $modifiers1) . "'"; |
|
| 555 | - $modifier2 = empty($modifiers2) ? '' : ", '" . implode("', '", $modifiers2) . "'"; |
|
| 554 | + $modifier1 = empty($modifiers1) ? '' : ", '".implode("', '", $modifiers1)."'"; |
|
| 555 | + $modifier2 = empty($modifiers2) ? '' : ", '".implode("', '", $modifiers2)."'"; |
|
| 556 | 556 | |
| 557 | 557 | return "strftime('%s', $date1$modifier1) - strftime('%s', $date2$modifier2)"; |
| 558 | 558 | } |