New method CDbCommandBuilder::createMultipleInsertCommand()
There's 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();
Example:
Use Like this....
$alertStatus[] = array(
'db_field_name1' => $value1,
'db_field_name1' => $value2,
'created_on' => new CDbExpression('NOW()'),
'modified_on' => new CDbExpression('NOW()')
);
$connection = Yii::app()->db->getSchema()->getCommandBuilder();
$command = $connection->createMultipleInsertCommand('table_name', $alertStatus);
$command->execute();
There's 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();
Example:
Use Like this....
$alertStatus[] = array(
'db_field_name1' => $value1,
'db_field_name1' => $value2,
'created_on' => new CDbExpression('NOW()'),
'modified_on' => new CDbExpression('NOW()')
);
$connection = Yii::app()->db->getSchema()->getCommandBuilder();
$command = $connection->createMultipleInsertCommand('table_name', $alertStatus);
$command->execute();
No comments:
Post a Comment