@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function getTableName($table) |
| 45 | 45 | { |
| 46 | - return '{{%' . str_replace($this->db->tablePrefix, '', $table->name) . '}}'; |
|
| 46 | + return '{{%'.str_replace($this->db->tablePrefix, '', $table->name).'}}'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - return '$this->batchInsert("{{%test}}", ' . $rows . ', ' . $columns . ');'; |
|
| 55 | + return '$this->batchInsert("{{%test}}", '.$rows.', '.$columns.');'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | foreach ($data as $row) { |
| 77 | 77 | $rows = ''; |
| 78 | 78 | foreach ($row as $value) { |
| 79 | - $rows .= "'" . addslashes($value) . "',"; |
|
| 79 | + $rows .= "'".addslashes($value)."',"; |
|
| 80 | 80 | } |
| 81 | - self::$rows .= "\n\t\t\t" . self::dataFormat($rows) . ","; |
|
| 81 | + self::$rows .= "\n\t\t\t".self::dataFormat($rows).","; |
|
| 82 | 82 | } |
| 83 | 83 | if (!empty(self::$rows)) { |
| 84 | 84 | return self::dataFormat(self::$rows); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | if (null !== $trim) { |
| 97 | 97 | $data = rtrim($data, $trim); |
| 98 | 98 | } |
| 99 | - return self::$dataEncloser[0] . $data . self::$dataEncloser[1]; |
|
| 99 | + return self::$dataEncloser[0].$data.self::$dataEncloser[1]; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $data = rtrim($data, $trim); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return self::$columnEncloser[0] . rtrim($data, $trim) . self::$columnEncloser[1]; |
|
| 113 | + return self::$columnEncloser[0].rtrim($data, $trim).self::$columnEncloser[1]; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | throw new Exception("The 'db' option must refer to the application component ID of a DB connection."); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $path = (string)Yii::getAlias($this->migrationPath); |
|
| 92 | + $path = (string) Yii::getAlias($this->migrationPath); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | if (!is_dir($path)) { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function getCreateTableSql($table) |
| 186 | 186 | { |
| 187 | - $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne(); |
|
| 187 | + $row = $this->db->createCommand('SHOW CREATE TABLE '.$this->quoteTableName($table->fullName))->queryOne(); |
|
| 188 | 188 | if (isset($row['Create Table'])) { |
| 189 | 189 | $sql = $row['Create Table']; |
| 190 | 190 | } else { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function actionUpData($limit = 0) |
| 209 | 209 | { |
| 210 | - $this->migrationPath .= DIRECTORY_SEPARATOR . $this->dataMigrationFolder; |
|
| 210 | + $this->migrationPath .= DIRECTORY_SEPARATOR.$this->dataMigrationFolder; |
|
| 211 | 211 | return parent::actionUp($limit); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | public function actionTable(array $tables) |
| 223 | 223 | { |
| 224 | 224 | |
| 225 | - if ($this->confirm('Create the migration ' . "?")) { |
|
| 225 | + if ($this->confirm('Create the migration '."?")) { |
|
| 226 | 226 | |
| 227 | 227 | foreach ($tables as $key => $tableName) { |
| 228 | 228 | |
| 229 | - $this->class = 'create_table_' . $tableName; |
|
| 229 | + $this->class = 'create_table_'.$tableName; |
|
| 230 | 230 | |
| 231 | 231 | try { |
| 232 | 232 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $this->table = $this->getTableName($table); |
| 252 | 252 | |
| 253 | 253 | foreach ($table->columns as $col) { |
| 254 | - $up .= "\t\t\t" . '\'' . $col->name . '\'=>"' . $this->getColType($col) . '",' . "\n"; |
|
| 254 | + $up .= "\t\t\t".'\''.$col->name.'\'=>"'.$this->getColType($col).'",'."\n"; |
|
| 255 | 255 | if ($col->isPrimaryKey) { |
| 256 | 256 | // Add column to composite primary key array |
| 257 | 257 | $compositePrimaryKeyCols[] = $col->name; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $ukeys = $this->db->schema->findUniqueIndexes($table); |
| 262 | 262 | if (!empty($ukeys)) { |
| 263 | - $indexArr =[]; |
|
| 263 | + $indexArr = []; |
|
| 264 | 264 | foreach ($ukeys as $key => $value) { |
| 265 | 265 | $indexKey = $key; |
| 266 | 266 | foreach ($value as $id => $field) { |
@@ -268,15 +268,15 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | $indexStr = implode(',', $indexArr); |
| 271 | - $up .= "\t\t" . '$this->createIndex(\'idx_' . $indexKey . "', '" . $this->getTableName($table) . "', '$indexStr', TRUE);\n"; |
|
| 271 | + $up .= "\t\t".'$this->createIndex(\'idx_'.$indexKey."', '".$this->getTableName($table)."', '$indexStr', TRUE);\n"; |
|
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | if (!empty($table->foreignKeys)): |
| 276 | 276 | |
| 277 | 277 | foreach ($table->foreignKeys as $fkName => $fk) { |
| 278 | - $addForeignKeys .= "\t\t" . '$this->addForeignKey("' . $fkName . '", "' . $table->name . '", "' . $fk['column'] . '","' . $fk['table'] . '","' . $fk['ref_column'] . '", "' . $fk['delete'] . '", "' . $fk['update'] . '");' . "\n"; |
|
| 279 | - $dropForeignKeys .= '$this->dropForeignKey(' . "'$fkName', '$table->name');"; |
|
| 278 | + $addForeignKeys .= "\t\t".'$this->addForeignKey("'.$fkName.'", "'.$table->name.'", "'.$fk['column'].'","'.$fk['table'].'","'.$fk['ref_column'].'", "'.$fk['delete'].'", "'.$fk['update'].'");'."\n"; |
|
| 279 | + $dropForeignKeys .= '$this->dropForeignKey('."'$fkName', '$table->name');"; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | endif; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | $fields = $this->parseFields(); |
| 287 | 287 | |
| 288 | - $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields]) . "\n\n"; |
|
| 288 | + $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields])."\n\n"; |
|
| 289 | 289 | |
| 290 | 290 | } |
| 291 | 291 | |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | public function actionData(array $tables) |
| 302 | 302 | { |
| 303 | 303 | |
| 304 | - if ($this->confirm('Create the migration ' . "?", true)) { |
|
| 304 | + if ($this->confirm('Create the migration '."?", true)) { |
|
| 305 | 305 | foreach ($tables as $key => $args) { |
| 306 | 306 | |
| 307 | 307 | $table = $args; |
| 308 | - $this->class = 'insert_data_into_' . $table; |
|
| 308 | + $this->class = 'insert_data_into_'.$table; |
|
| 309 | 309 | $this->table = $table; |
| 310 | 310 | $this->templateFile = '@tmukherjee13/migration/views/dataTemplate.php'; |
| 311 | 311 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $pcolumns = ''; |
| 335 | 335 | foreach ($columns->columns as $column) { |
| 336 | - $pcolumns .= "'" . $column->name . "',"; |
|
| 336 | + $pcolumns .= "'".$column->name."',"; |
|
| 337 | 337 | } |
| 338 | 338 | foreach ($data as $row) { |
| 339 | 339 | array_push($prepared_data, $row); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $prows = $this->prepareData($prepared_data); |
| 347 | 347 | |
| 348 | 348 | if ($this->useDataMigrationFolder) { |
| 349 | - $path = $this->migrationPath . DIRECTORY_SEPARATOR . $this->dataMigrationFolder; |
|
| 349 | + $path = $this->migrationPath.DIRECTORY_SEPARATOR.$this->dataMigrationFolder; |
|
| 350 | 350 | FileHelper::createDirectory($path); |
| 351 | 351 | $this->migrationPath = $path; |
| 352 | 352 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | { |
| 369 | 369 | |
| 370 | 370 | $schema = $args; |
| 371 | - $this->class = 'dump_database_' . $schema; |
|
| 371 | + $this->class = 'dump_database_'.$schema; |
|
| 372 | 372 | |
| 373 | 373 | // $tables = $this->db->schema->getTableNames($schema); |
| 374 | 374 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | $generateTables = []; |
| 384 | 384 | |
| 385 | 385 | foreach ($tables as $table) { |
| 386 | - if ($table->name === $this->db->tablePrefix . $this->migrationTable) { |
|
| 386 | + if ($table->name === $this->db->tablePrefix.$this->migrationTable) { |
|
| 387 | 387 | continue; |
| 388 | 388 | } |
| 389 | 389 | $generateTables[] = $table->name; |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | public function getFileName() |
| 397 | 397 | { |
| 398 | - return 'm' . gmdate('ymd_His') . '_' . $this->class; |
|
| 398 | + return 'm'.gmdate('ymd_His').'_'.$this->class; |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | public function setFileName() |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | public function prepareFile($data) |
| 407 | 407 | { |
| 408 | - $file = $this->migrationPath . DIRECTORY_SEPARATOR . $this->getFileName() . '.php'; |
|
| 408 | + $file = $this->migrationPath.DIRECTORY_SEPARATOR.$this->getFileName().'.php'; |
|
| 409 | 409 | try { |
| 410 | 410 | |
| 411 | 411 | $data['table'] = $this->table; |