Hi,
is there a way to create a mass-insert with CActiveRecord Models instead of saving them one-by-one in a loop? Otherwise I have to use plain SQL because its important to have a very good performance.
thanks
Hi,
is there a way to create a mass-insert with CActiveRecord Models instead of saving them one-by-one in a loop? Otherwise I have to use plain SQL because its important to have a very good performance.
thanks
you can’t do it with AR. version 1.1.14 includes a helper
New method CDbCommandBuilder::createMultipleInsertCommand()
There is now CDbCommandBuilder::createMultipleInsertCommand() to support insertion of multiple records in a single query:
$builder=Yii::app()->db->schema->commandBuilder;
$command=$builder->createMultipleInsertCommand('tbl_post', array(
array('title' => 'record 1', 'text' => 'text1'),
array('title' => 'record 2', 'text' => 'text2'),
));
$command->execute();
Ok thank you.