$usrmodel = new Tempcategory;
$temp_id = $tempid;
$ct_id = $ctid;
$inarray=array();
if(is_array($inarray))
{
foreach(array($ct_id) as $catid)
{
$inarray[]=array('temp_id'=>$temp_id,'ct_id'=>$catid);
}
if(count($inarray)>0)
{
GeneralRepository::insertSeveral($usrmodel->tableName(),$inarray);
}
}
我有三张桌子..
- 类别 ct_id主要 ct_name
模板 temp_id主要 t_name
- 醇>
tempcategory temp_cid主要 ct_id fk temp_id fk
我需要在db中保存如下
temp-id ct_id
1 1
1 2
1 3
答案 0 :(得分:0)
$usrmodel = new Tempcategory;
$temp_id = $tempid;
$ct_id = $ctid;
$new = explode(" ", $ct_id);
// print_r($new);
$inarray=array();
foreach($new as $catid)
{
$inarray[]=array('temp_id'=>$temp_id,'ct_id'=>$catid);
}
if(count($inarray)>0)
{
GeneralRepository::insertSeveral($usrmodel->tableName(),$inarray);
}
解决了.........