通过关键字查阅很多问答,最后采用了官方给出的建议。
就是不用自带的buildparams 方法,而是自行构造相应的查询条件。
$uid = Session::get('admin.id');$filter = $this->request->get("filter", '');$filter = (array)json_decode($filter, true);$sort = $this->request->get("sort", "id");$order = $this->request->get("order", "DESC");$offset = $this->request->get("offset", 0);$limit = $this->request->get("limit", 0);//对于 = 条件的不再赘述,日期时间类的还是做些调整,废话不多,直接上代码$where = [];$where[] = ['a.admin_id', '=', $uid];if (!empty($filter)) { foreach ($filter as $k=>$v) { if (in_array($k, ['create_time'])) { $condition = explode(' - ', $v); $condition_time = array_map('strtotime', $condition); $where[] = ['b.'.$k, 'BETWEEN', $condition_time]; } else { $where[] = ['b.'.$k, '=', $v]; } }}
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。