0
在,yii2我要插入一個表上的單層排以及具有相同ID的多個行中另一臺在,yii2我要插入一個表上的單層排以及多排在另一個表
controller code --
$modelcid = $modeld->categoryid;
$modelpc = $modeld->productcode;
$modelqty = $modeld->qty;
$arrayvalue[]= array('id'=>$modelcid,'pc'=>$modelpc,'qty'=>$modelqty);
$i=0;
foreach($arrayvalue as $key=>$val) {
\t $purchaseid = $modeld->purchaseid = $modelm->purchaseid;
\t $cid = $modeld->categoryid =$val['id'][$i];
\t $pc = $modeld->productcode = $val['pc'][$i];
\t $qty = $modeld->qty = $val['qty'][$i];
\t $remarks = $modeld->remarks = $modelm->remarks;
\t if($modeld->save()){
\t \t \t $i++;
\t \t }
\t }
"$modeld->save()" it saves only first entry.