PHP多表联查的分页

使用tp5的Db类进行操作

$count是符合条件的数据量

<div class="col-xs-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>搜索</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="table-responsive">

                            <form class="form-search" method="get" action="<?=url('automatic.order/integarlOrder')?>" role="form">

                                <table>

                                    <tr>

                                        <td>联系人:<input class="form-control" name="name" id="name"

                                                       value="<?=$search['name']?>" type="text" placeholder="请输入联系人"

                                                       style=" width:200px"/></td>

                                        <td>手机号码:<input class="form-control" name="mobile" id="mobile"

                                                        value="<?=$search['mobile']?>" type="text" placeholder="请输入手机号码"

                                                        style=" width:200px"/></td>



                                        <td>

                                            <div class="input-group">

                                                <button type="submit" style="margin-top: 42%"

                                                        class="btn form-control btn-sm btn-primary">

                                                    搜索

                                                </button>

                                            </div>

                                        </td>

                                    </tr>



                                </table>



                            </form>



                        </div>

                    </div>

                </div>

            </div>

        </div>

 

/*
author:咔咔
address:陕西西安
wechat:fangkangfk
*/

 public function vipOrder()
    {
        $where = $search = [];
        $search['name'] = $this->request->param('name');
        if (!empty($search['name'])) {
            $where['nickname'] = array('LIKE', '%' . $search['name'] . '%');
        }
        $search['mobile'] = $this->request->param('mobile');
        if (!empty($search['mobile'])) {
            $where['mobile'] = array('LIKE', '%' . $search['mobile'] . '%');
        }
        $where['scale'] = 1;
        $count = Db::table('wxb_move_order')
            ->where($where)
            ->alias('o')
            ->join('wxb_move_user u','o.user_id = u.id')
            ->count();
        $list = Db::table('wxb_move_order')
            ->where($where)
            ->alias('o')
            ->join('wxb_move_user u','o.user_id = u.id')
            ->paginate(3, $count);
        $page = $list->render();
        $this->assign('page', $page);
        $this->assign('list', $list);
        $this->assign('search', $search);
        return $this->fetch();
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咔咔-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值