startTrans(); foreach ($data as $key => $value) { if ($value['id'] != ""&&$value['image']!="") { //修改数据 $res = $this->dataUpdate($value); }else{ if($value['image']==''){ //删除数据 $res = $this->destroy(['id'=>$value['id']]); }else{ //新增数据 unset($value['id']); $res = $this->dataUpdate($value); } } if ($res === false) { $this->rollBack(); return false; } } $this->commit(); return true; } } }