create(); if(!$data){ return false; } $open_data = $this->getUserData($user_id); if(empty($open_data)){//添加 $data['dep_id'] = $user_id; $result = $this->add($data); }else{//编辑 $map['id'] = $open_data['id']; $map['dep_id'] = $user_id; $result = $this->where($map)->save($data); } return $result; } /** * 获取用户数据 * @return mixed * author: xmy 280564871@qq.com */ public function getUserData($user_id){ $map['dep_id'] = $user_id; return $this->where($map)->find(); } }