db\Command batchInsert()

batchInsert() public method

Creates a batch INSERT command.

For example,

$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 execute() is called.

public $this batchInsert ( $table, $columns, $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

return $this

The command object itself

doc_Yii
2016-10-30 16:57:21
Comments
Leave a Comment

Please login to continue.