时间段搜索

first:
        $time_start = I('time_start') ? date("Y-m-d 00:00:00", strtotime(I('time_start'))) : null;
        $time_end   = I('time_end')   ? date("Y-m-d 23:59:59", strtotime(I('time_end'))) : null;
        I('time_start') ? $where['time'] = ['egt', $time_start] : null;
        I('time_end')   ? $where['time'] = ['elt', $time_end] : null;
        I('time_start') && I('time_end') ? $where['time'] =['between', [$time_start, $time_end]] : null;

second:
        $time_start = trim($this->request->get('time_start')) ? strtotime(trim($this->request->get('time_start'))) : null;
        $time_end = trim($this->request->get('time_end')) ? strtotime(trim($this->request->get('time_end'))) : null;
        //日期搜索
        $time_start ? $where['f_user_entry'] = ['egt', $time_start] : null;
        $time_end ? $where['f_user_entry'] =['elt', $time_end] : null;
        $time_start && $time_end ? $where['f_user_entry'] = ['between', [$time_start, $time_end]] : null;
        //分页
        $p = $this->request->get('p');
        (empty($p) || !is_numeric($p)) && $p = 1;
        $limit = $this->request->get('limit');
        (empty($limit) || !is_numeric($limit)) && $limit = 15;

  

posted @ 2018-11-26 14:01  王芬老师  阅读(242)  评论(0编辑  收藏  举报