public function actionCreate()
{
$model=new PurchaseRecord;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['PurchaseRecord']))
{
$insertion_query=array();
$model->attributes=$_POST['PurchaseRecord'];
foreach ($model->things_id as $value)
$insertion_query[]="($model->purchase_id,$value)";
$insertion_query1='INSERT INTO purchase_record(purchase_id,things_id) VALUES'.implode(',', $insertion_query);
if($model->dbConnection->createCommand("$insertion_query1")->execute())
$this->redirect(array('admin'));
}
$this->render('create',array(
'model'=>$model,
));
}
I have a multiple select option for things so things id will have array of value
could i use like this or any good method available?
As nobody answered, you can assume that nobody got a similar need… so there is no practice for this
As I see it… If it works… than it’s OK…
One other solution would be to create a new model… assign the value and use $model->save(), but it would be much, much slower than this solution… so for your practical need this is just fine…