获取所有记录(带查询条件、分页)

获取所有记录(带查询条件、分页)

  //获取所有记录
    public function table() {


            if (isset($_GET['reservation_type'])) {
                $map['reservation_type'] = $_GET['reservation_type'];
            }

            if (isset($_GET['keyword'])) {
                $where['name'] = array('like', '%' . $_GET['keyword'] . '%');
                $where['phone'] = array('like', '%' . $_GET['keyword'] . '%');
                $where['store'] = array('like', '%' . $_GET['keyword'] . '%');
                $where['receiver'] = array('like', '%' . $_GET['keyword'] . '%');
                $where['_logic'] = 'or';
                $map['_complex'] = $where;
            }

            
            $reservation = M('customer_reservation_record');
            $count = $reservation->where($map)->count(); // 查询满足要求的总记录数

            $Page = new \Think\Page($count, 10); // 实例化分页类 传入总记录数和每页显示的记录数(25)
            $show = $Page->show(); // 分页显示输出
            // 进行分页数据查询 注意limit方法的参数要使用Page类的属性

            $limit = $Page->firstRow . ',' . $Page->listRows;

            $sort = "crr_id desc";
            $list = $reservation->where($map)->limit($limit)->order($sort)->select();

            $this->assign('list', $list); // 赋值数据集
            $this->assign('page', $show); // 赋值分页输出
            $this->display(); // 输出模板

    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值