yii\db\Migration::batchInsert PHP Method

batchInsert() public method

The method will properly escape the column names, and bind the values to be inserted.
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)
    {
        echo "    > insert into {$table} ...";
        $time = microtime(true);
        $this->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function batchInsert($table, $columns, $rows)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::batchInsert($table, $columns, $rows);
 }