后端开发|php教程
Laravel5,加多,匹配
后端开发-php教程方法1. ORM模式
虚拟 销售 源码,vscode编辑器放大,ubuntu主题核心,tomcat 应用名变量,网易股票爬虫,php判断一维数组,seo关键词价格多少,云购夺宝网站架设,dedecms html5模板免费下载lzw
public function ReportAccurate($data){ if(is_array($data)) { $where = $this->whereAll($data); return $where; } else { return false; }}/*多条件模糊*/public function whereAll($data){ $query = new ReportMainpage(); $results = $query->where(function ($query) use ($data) { $data[ eport_first_received_date] && $query->where( eport_first_received_date, like, \% . $data[ eport_first_received_date] . \%); $data[ eport_drug_safety_date] && $query->where( eport_drug_safety_date, like, \% . $data[ eport_drug_safety_date] . \%); $data[aecountry_id] && $query->where(aecountry_id, $data[aecountry_id]); $data[ eceived_fromid_id] && $query->where( eceived_fromid_id, $data[ eceived_fromid_id]); $data[ esearch_id] && $query->where( esearch_id, like, \% . $data[ esearch_id] . \%); $data[center_number] && $query->where(center_number, like, \% . $data[center_number] . \%); })->get(); return $results;}
上面的$data为前端传过来的数组 利用封装拼接进行模糊或者精确的多条件搜素
qq综合工具箱源码,vscode怎么编两行,ubuntu启动dhcp,内嵌tomcat怎么用,python 爬虫面试,php md5性能,越秀区seo账户托管机构,源程序网站lzw
不好的地方 代码不健壮 不利于维护
糗趣兔源码,vue3 vscode 插件,ubuntu flex,tomcat 生命周期,ado sqlite,如何制作手机端网页设计,phocms数据库位置,万网轻云服务器 伪静态,rec插件,红旗前端框架,播放的爬虫,php打开乱码,成都网站seo公司,springboot异步代码,dede首页缩略图标签,网易云音乐网站源代码,圆形菜单网页,网站模板制作工具,手机后台限制进程的弊端,多页面提交系统源码,5ucms网站管理系统,人人商城小程序前端后端源码lzw
方法2. 大神封装法 利用到的知识是Repository 仓库
$fields = [id, eport_id, eport_identify, eport_first_received_date, drug_name, first_event_term, case_serious, standard_of_seriousness, case_causality, eceived_from_id, ask_user_name, organize_role_name, ask_countdown, eport_countdown];/*查询的字段*/$searchFields = [ eport_identify => like, drug_name => like, event_term => like, organize_role_id => =, case_causality => =, eport_type => =, ask_user_id => =, status => =,];/*获取查询条件*/$where = $this->searchArray($searchFields);/*获取数据*/$this->reportTaskRepo->pushCriteria(new OrderBySortCriteria(asc, ask_countdown));$data = $this->reportTaskRepo->findWhere($where, $fields);//在Trait里封装/** * 获取请求中的参数的值 * @param array $fields [description] * @return [type][description] */public function searchArray($fields=[]){ $results = []; if (is_array($fields)) { foreach($fields as $field => $operator) {if(request()->has($field) && $value = $this->checkParam($field, \, false)) {$results[$field] = [$field, $operator, "%{$value}%"];} } } return $results;}