メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Model::insertRows

Insert several rows in one transaction

Description​

public array Model::insertRows( array $rows )

Inserts each row with insertRow inside one transaction and returns the new IDs in order. When one row fails, none is inserted and the exception is rethrown. Throws InvalidArgumentException when an element of $rows is not an array.

Arguments​

NameData typeDefaultRemarks
$rowsarrayList of rows (column => value arrays)

Example​

Controller
$model = new Model(true, array(
'table' => 'cms_news',
'id' => 'news_id',
'visible' => 'visible',
));

$ids = $model->insertRows(array(
array('title' => 'First', 'category' => 1),
array('title' => 'Second', 'category' => 2),
));
// -> array(25, 26)