created two migrations for table_a and table_b#1
Open
molefirenko wants to merge 1 commit into
Open
Conversation
created two console scripts for fill table_a with data move data from table_a to table_b
primemix
reviewed
May 18, 2019
| } | ||
| Console::endProgress('done'.PHP_EOL); | ||
|
|
||
| return 0; |
primemix
reviewed
May 18, 2019
| { | ||
| $security = new Security(); | ||
|
|
||
| Console::startProgress(0,$this->records_count); |
There was a problem hiding this comment.
Console::startProgress(0, $this->records_count);
и ноль (цифры) желательно константой писать
primemix
reviewed
May 18, 2019
| $security = new Security(); | ||
|
|
||
| Console::startProgress(0,$this->records_count); | ||
| for( $i=0;$i<$this->records_count;$i++ ) { |
There was a problem hiding this comment.
for ($i = 0; $i <= $this->records_count; $i++)
primemix
reviewed
May 18, 2019
|
|
||
| Console::startProgress(0,$this->records_count); | ||
| for( $i=0;$i<$this->records_count;$i++ ) { | ||
| Yii::$app->db->createCommand()->insert('table_a',['value'=>$security->generateRandomString(8)])->execute(); |
There was a problem hiding this comment.
Yii::$app->db->createCommand()
->insert('table_a',['value'=>$security->generateRandomString(8)])
->execute();
и восемь константой, если не ясно почему могу объяснить
primemix
reviewed
May 18, 2019
| Console::startProgress(0,$this->records_count); | ||
| for( $i=0;$i<$this->records_count;$i++ ) { | ||
| Yii::$app->db->createCommand()->insert('table_a',['value'=>$security->generateRandomString(8)])->execute(); | ||
| Console::updateProgress($i,$this->records_count); |
There was a problem hiding this comment.
Console::updateProgress($i, $this->records_count);
primemix
reviewed
May 18, 2019
|
|
||
| Yii::$app->db->createCommand()->batchInsert('table_b',['id','value'],$data_a)->execute(); | ||
|
|
||
| return 0; |
primemix
reviewed
May 18, 2019
| * @return int | ||
| * @throws yii\db\Exception | ||
| */ | ||
| public function actionIndex() |
primemix
reviewed
May 18, 2019
| { | ||
| $data_a = Yii::$app->db->createCommand('SELECT * FROM table_a')->queryAll(); | ||
|
|
||
| Yii::$app->db->createCommand()->batchInsert('table_b',['id','value'],$data_a)->execute(); |
There was a problem hiding this comment.
Yii::$app->db->createCommand()
->batchInsert('table_b', ['id','value'], $data_a)
->execute();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
created two migrations for table_a and table_b
created two console scripts for fill table_a with data and move data from table_a to table_b