mid] ]; return $this->where($where)->field('image,link_url')->order('sort desc')->select()->toArray(); } /** * 修改轮播图 * @param $data * @return bool */ public function dataUpdateByAll($data) { if (empty($data)) { return false; } else { $this->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; } } }