Do Yii have insertAll funtion like updateAll? here is my controller and I need to insert data from one table to another table using check box.
this is from table A view file
<?php echo CHtml::beginForm(array(‘multirequest’))?>
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'testgrid',
'dataProvider'=>$model->test(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'Select', 'value'=>'CHtml::checkBox("cid[]",null,array("value"=>$data->id,"id"=>"cid_".$data->id))',
'type'=>'raw',
'htmlOptions'=>array('width'=>5),
//'visible'=>false,
),
array(
'name'=>'C_id',
'value'=>'$data->cat->name',
),
array(
'name'=>'S_c_id',
'value'=>'$data->s_cat->name',
),
'name',
'food',
),
)); ?>
<?php echo CHtml::submitButton(‘Submit’, array(‘submit’=>array(‘multirequest’))) ;?>
<?php echo CHtml::endForm(); ?>
data will go to table B:
controller
public function actionMultirequest()
{
if ($_POST["cid"] == 0)
{
throw new CHttpException(400,'You did not select any data.');
$this->redirect(array('test'));
} else {
$this->_model=B::model()->insertAll(array("user_Id"=> Yii::app()->user->id),"id IN (" .implode(",",$_POST["cid"]).")");
$this->redirect(array('admin'));
}
}