|
@@ -33,7 +33,7 @@ discard block |
|
|
block discarded – undo |
|
33
|
33
|
public function actionLoad($truncateMode = false) |
|
34
|
34
|
{ |
|
35
|
35
|
$startTime = microtime(true); // check time of start execution script |
|
36
|
|
- $startMemory = round(memory_get_usage(true) / 1048576, 2); |
|
|
36
|
+ $startMemory = round(memory_get_usage(true)/1048576, 2); |
|
37
|
37
|
|
|
38
|
38
|
echo "\033[36m Are you sure you want to load fixtures? Your database will be purged! [Y/N] \033[0m"; |
|
39
|
39
|
|
|
@@ -47,7 +47,7 @@ discard block |
|
|
block discarded – undo |
|
47
|
47
|
} |
|
48
|
48
|
|
|
49
|
49
|
// assign file variable what consist full path to fixtures file |
|
50
|
|
- $file = empty($this->pathToFixtures) ? __DIR__ . '/fixtures.php' : $this->pathToFixtures; |
|
|
50
|
+ $file = empty($this->pathToFixtures) ? __DIR__.'/fixtures.php' : $this->pathToFixtures; |
|
51
|
51
|
|
|
52
|
52
|
// import models classes to make available create new instances |
|
53
|
53
|
if (empty($this->modelsFolder)) { // if property empty default load form the models folder in protected directory |
|
@@ -77,7 +77,7 @@ discard block |
|
|
block discarded – undo |
|
77
|
77
|
$keys = array(); // prepare array for store FK`s data |
|
78
|
78
|
foreach (Yii::app()->db->schema->getTables() as $tableSchema) { // Run over all tables |
|
79
|
79
|
$parser = new PHPSQLParser(); |
|
80
|
|
- $result = Yii::app()->db->createCommand('SHOW CREATE TABLE ' . $tableSchema->name)->queryRow(); // getting create sql statement for current table |
|
|
80
|
+ $result = Yii::app()->db->createCommand('SHOW CREATE TABLE '.$tableSchema->name)->queryRow(); // getting create sql statement for current table |
|
81
|
81
|
$parsed = $parser->parse($result['Create Table']); //parse sql create statement |
|
82
|
82
|
$table = $parsed['TABLE']['base_expr']; // get table name |
|
83
|
83
|
foreach ($parsed['TABLE']['create-def']['sub_tree'] as $key => $column_def) { // run over all columns of the table |
|
@@ -129,7 +129,7 @@ discard block |
|
|
block discarded – undo |
|
129
|
129
|
foreach ($errorList as $key => $errors) { // run over all errors and display error what occur during saving into db |
|
130
|
130
|
foreach ($errors as $k => $error) { |
|
131
|
131
|
foreach ($error as $i => $value) { |
|
132
|
|
- echo "\033[37;41m" . $value . "\033[0m \n"; //display error |
|
|
132
|
+ echo "\033[37;41m".$value."\033[0m \n"; //display error |
|
133
|
133
|
} |
|
134
|
134
|
} |
|
135
|
135
|
} |
|
@@ -137,10 +137,10 @@ discard block |
|
|
block discarded – undo |
|
137
|
137
|
} |
|
138
|
138
|
|
|
139
|
139
|
echo "\033[37;42m All fixtures loaded properly \033[0m \n |
|
140
|
|
- Script execution time: " . round(microtime(true) - $startTime, 2) . " ms. \n"; |
|
|
140
|
+ Script execution time: " . round(microtime(true) - $startTime, 2)." ms. \n"; |
|
141
|
141
|
|
|
142
|
|
- $endMemory = round(memory_get_usage(true) / 1048576, 2); |
|
143
|
|
- echo "Memory used: " . ($endMemory - $startMemory) . "mb \n"; |
|
|
142
|
+ $endMemory = round(memory_get_usage(true)/1048576, 2); |
|
|
143
|
+ echo "Memory used: ".($endMemory - $startMemory)."mb \n"; |
|
144
|
144
|
} |
|
145
|
145
|
|
|
146
|
146
|
/** |
|
@@ -153,6 +153,6 @@ discard block |
|
|
block discarded – undo |
|
153
|
153
|
$output = "\033[34m This command will allow you to manage your fixtures in a simple way. |
|
154
|
154
|
Be careful all rows from database will be removed! \033[0m \n\n"; |
|
155
|
155
|
|
|
156
|
|
- return $output . parent::getHelp(); |
|
|
156
|
+ return $output.parent::getHelp(); |
|
157
|
157
|
} |
|
158
|
158
|
} |