yii\db\Command::batchInsert PHP Method

batchInsert() public method

For example, php $connection->createCommand()->batchInsert('user', ['name', 'age'], [ ['Tom', 30], ['Jane', 20], ['Linda', 25], ])->execute(); The method will properly escape the column names, and quote the values to be inserted. Note that the values in each row must match the corresponding column names. Also note that the created command is not executed until Command::execute is called.
public batchInsert ( string $table, array $columns, array $rows )
$table string the table that new rows will be inserted into.
$columns array the column names
$rows array the rows to be batch inserted into the table
    public function batchInsert($table, $columns, $rows)
    {
        $sql = $this->db->getQueryBuilder()->batchInsert($table, $columns, $rows);
        return $this->setSql($sql);
    }