微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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();
    }

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐