$where = []; //条件的成立 $select = $this->request->get('filter', ''); if (!empty($select)) { $filter = (array)json_decode($select, TRUE); $filter = $filter ? $filter : []; foreach ($filter as $k => $v) { if($k == 'time') { $v = str_replace(' - ', ',', $v); $arr = array_slice(explode(',', $v), 0, 2); if (stripos($v, ',') === false || !array_filter($arr)) continue; //当出现一边为空时改变操作符 if ($arr[0] === '') { $arr = $arr[1]; } else if ($arr[1] === '') { $arr = $arr[0]; } $where['into_time'] = ['BETWEEN', [strtotime($arr[0]),strtotime($arr[1])]]; } } } $sort = $this->request->get("sort", "id"); //自定义排序字段 $order = $this->request->get("order", "DESC"); $offset = $this->request->get("offset", 0); $limit = $this->request->get("limit", 0); //也可以这么用 list($sort, $order, $offset, $limit) = $this->buildparams();
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。