Skip to content

created two migrations for table_a and table_b#1

Open
molefirenko wants to merge 1 commit into
masterfrom
dev
Open

created two migrations for table_a and table_b#1
molefirenko wants to merge 1 commit into
masterfrom
dev

Conversation

@molefirenko
Copy link
Copy Markdown
Owner

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

created two console scripts for fill table_a with data
	move data from table_a to table_b
}
Console::endProgress('done'.PHP_EOL);

return 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут return 0; - не нужно.

{
$security = new Security();

Console::startProgress(0,$this->records_count);
Copy link
Copy Markdown

@primemix primemix May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console::startProgress(0, $this->records_count);
и ноль (цифры) желательно константой писать

$security = new Security();

Console::startProgress(0,$this->records_count);
for( $i=0;$i<$this->records_count;$i++ ) {
Copy link
Copy Markdown

@primemix primemix May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for ($i = 0; $i <= $this->records_count; $i++)


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();
Copy link
Copy Markdown

@primemix primemix May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yii::$app->db->createCommand()
->insert('table_a',['value'=>$security->generateRandomString(8)])
->execute();

и восемь константой, если не ясно почему могу объяснить

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console::updateProgress($i, $this->records_count);


Yii::$app->db->createCommand()->batchInsert('table_b',['id','value'],$data_a)->execute();

return 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 0; - не нужен

* @return int
* @throws yii\db\Exception
*/
public function actionIndex()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function actionIndex(): void

{
$data_a = Yii::$app->db->createCommand('SELECT * FROM table_a')->queryAll();

Yii::$app->db->createCommand()->batchInsert('table_b',['id','value'],$data_a)->execute();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yii::$app->db->createCommand()
->batchInsert('table_b', ['id','value'], $data_a)
->execute();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants