苏州网站建设在利用ThinkPHP添加个人简历的方法
/** * 我的简历 * @author wusn <message@jswusn.com> */ public function myResume(){ $userInfo = $this->user_info(); $uid = $userInfo['id']; $db = M('member'); if(IS_POST){ $data = I(); $data['user']['birth_time'] = strtotime($data['user']['birth_time']); unset($data['user']['mobile']); unset($data['user']['email']); //验证教育经历 $edu_validate = array( array('school','require','毕业学校必填!'), array('major','require','专业必填!'), array('start_time','require','起始时间必填!'), array('end_time','require','结束时间必填!'), ); foreach ($data['edu'] as $key=>$value){ if(!M('eduhistory')->validate($edu_validate)->create($value)){ $this->error(M('eduhistory')->getError()); } } //验证工作经历 if($data['work'] == 1){ $work_validate = array( array('corporate_name','require','公司名称必填!'), array('start_time','require','起始时间必填!'), array('end_time','require','结束时间必填!'), array('department','require','所属部门必填!'), array('zhiwei','require','职位必填!'), array('content','require','工作描述必填!'), ); foreach ($data['working'] as $key=>$value) { if (!M('working')->validate($work_validate)->create($value)) { $this->error(M('working')->getError()); } } } //保存用户基本信息 $result = $db->where(array('id'=>$uid))->save($data['user']); //添加教育经历 if(!empty($data['edu'])){ M('eduhistory')->where(array('uid'=>$uid))->delete(); foreach ($data['edu'] as $key=>$value){ $data['edu'][$key]['start_time'] = strtotime($data['edu'][$key]['start_time']); $data['edu'][$key]['end_time'] = strtotime($data['edu'][$key]['end_time']); $data['edu'][$key]['uid']=$uid; } M('eduhistory')->addAll($data['edu']); } //添加工作经验 if($data['work'] == 1) { if (!empty($data['working'])) { M('working')->where(array('uid' => $uid))->delete(); foreach ($data['working'] as $key => $value) { $data['working'][$key]['start_time'] = strtotime($data['working'][$key]['start_time']); $data['working'][$key]['end_time'] = strtotime($data['working'][$key]['end_time']); $data['working'][$key]['uid'] = $uid; } M('working')->addAll($data['working']); M('member')->where(array('id' => $uid))->save(array('is_work' => 1)); } } //添加工作项目 if(!empty($data['project'])){ M('project')->where(array('uid'=>$uid))->delete(); foreach ($data['project'] as $key=>$value){ $data['project'][$key]['start_time'] = strtotime($data['project'][$key]['start_time']); $data['project'][$key]['end_time'] = strtotime($data['project'][$key]['end_time']); $data['project'][$key]['uid']=$uid; } M('project')->addAll($data['project']); } //添加其他 if(!empty($data['other'])){ M('other')->where(array('uid'=>$uid))->delete(); $data['other']['uid'] = $uid; M('other')->add($data['other']); } M('member')->where(array('id'=>$uid))->save(array('is_work'=>1,'resume'=>1)); $this->success('更新成功'); }else{ $userInfo = $db->find($uid); $edu = M('eduhistory')->where(array('uid'=>$uid))->select(); $working = M('working')->where(array('uid'=>$uid))->select(); $project = M('project')->where(array('uid'=>$uid))->select(); $other = M('other')->where(array('uid'=>$uid))->find(); //教育经历时间转换 foreach ($edu as $key=>$value){ $edu[$key]['start_time'] = date( 'Y-m-d', $edu[$key]['start_time']); $edu[$key]['end_time'] = date( 'Y-m-d', $edu[$key]['end_time']); } //工作经历时间转换 foreach ($working as $key=>$value){ $working[$key]['start_time'] = date( 'Y-m-d', $working[$key]['start_time']); $working[$key]['end_time'] = date( 'Y-m-d', $working[$key]['end_time']); } //参与项目时间转换 foreach ($project as $key=>$value){ $project[$key]['start_time'] = date( 'Y-m-d', $project[$key]['start_time']); $project[$key]['end_time'] = date( 'Y-m-d', $project[$key]['end_time']); } $this->assign('userInfo',$userInfo); //Member表中 用户信息 $this->assign('edu_xingshi',$this->edu_xingshi()); //教育形式 $this->assign('education',$this->edu()); //教育 $this->assign('edu',json_encode($edu)); $this->assign('working',json_encode($working)); $this->assign('project',json_encode($project)); $this->assign('other',$other); $this->assign('rchannel',$this->rchannel()); $this->assign('work_time',$this->work_time()); $this->display(); } }
以上是苏州网站建设分享关于ThinkPHP添加个人简历的方法使用,如果你也有一些新颖的想法,可以跟苏州网站建设交流下。
苏州网站建设祝大家开工大吉~~~