时间段搜索

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'] = array('egt', $time_start) : null;
        I('time_end')   ? $where['time'] = array('elt', $time_end) : null;
        I('time_start') && I('time_end') ? $where['time'] = array('between', array($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'] = array('egt', $time_start) : null;
        $time_end ? $where['f_user_entry'] = array('elt', $time_end) : null;
        $time_start && $time_end ? $where['f_user_entry'] = array('between', array($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;

  

猜你喜欢

转载自www.cnblogs.com/wangfenphph2/p/10019959.html