A
A
AlexSer2019-03-28 08:53:07
Yii
AlexSer, 2019-03-28 08:53:07

How to put an array in a table in Yii2 migration?

Here is the code for creating and writing data... I don't like calling insert every time

public function safeUp()
    {
        $this->createTable('specialnost', [
            'id' => $this->primaryKey(),
            'title' => $this->string()->notNull(),
        ]);

        $this->insert('specialnost', [
            'title' => 'Администратор',
        ]);
        $this->insert('specialnost', [
            'title' => 'Бухгалтер',
        ]);
      ............
    }

How to do it in one code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2019-03-28
@kawabanga

$this->batchInsert()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question