public function badst(){
$this->title='食品信息';
$id = input('id');
$res=explode(',', $id);
$result =db('food_badst')->field('food_id')->select();
if($id){
foreach ($res as $k=>$v){
$arr = [['food_id'=>$v]];
$ids = db('food_badst')->insertAll($arr);
}
if($ids){
$this->success('添加成功',true);
}else{
$this->error('添加失败',false);
}
}else{
$this->error('失败',false);
}
}
关键条件加个判断不就是了