thinkphp 条件搜索分页(tp自带Page类)

thinkphp 条件搜索分页:
public function dadlist($request) 
    {    
        $npost = array_merge($_GET,$_POST);
        if(!empty($npost['status'])){
            $dds['status'] = $npost['status'];
        }
        if(!empty($npost['ordernum'])){
            $dds['ordernum'] = ['like',"%".$npost['ordernum']."%"];
        }
        if(!empty($npost['preordernum'])){
            $dds['preordernum'] = ['like',"%".$npost['preordernum']."%"];
        }
        if(!empty($npost['userid'])){
            $dds['userid'] = $npost['userid'];
        }
        $count = M('Dd')->where($dds)->count();
        $Page  = $page = new \Think\Page($count, 15,$npost);
        $show  = $Page->show();
        $list  = M('Dd')->where($dds)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
        //var_dump($list);die;
        $params = array(
            'ddlist' => $list,
            'count' => $count,
            'Page' => $show,
            'pageName' => '列表'
        );
                
        return [1,$params];
    }
View Code

 

 

——————————————

 

posted on 2017-12-05 16:13  逝年-  阅读(501)  评论(0编辑  收藏  举报