PHP多表联查的分页

简介: 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();
    }
相关文章
原生php实现列表接口+分页接口+排序接口组合使用+包括测试数据(不加任何封装)
原生php实现列表接口+分页接口+排序接口组合使用+包括测试数据(不加任何封装)
原生php实现列表接口+分页接口+排序接口组合使用+包括测试数据(不加任何封装)
|
2天前
|
SQL 前端开发 PHP
【PHP开发专栏】PHP分页功能的设计与实现
【4月更文挑战第29天】本文介绍了PHP实现分页功能,包括设计逻辑(用户界面和后端处理)、SQL查询优化和前端展示。后端通过计算页码和偏移量进行数据查询,前端展示分页信息并处理用户交互。优化点有使用索引、LIMIT语句和避免子查询。此外,还提到了无限滚动、AJAX分页和分页大小选择等高级功能,以提升用户体验。
|
8月前
|
关系型数据库 MySQL PHP
PHP 原生操作 Mysql 分页数据案例
PHP 原生操作 Mysql 分页数据案例
98 1
|
10月前
|
前端开发 JavaScript PHP
php使用mPDF实战案例分析字符串太长时文本变小无法自动分页的解决方案
php使用mPDF实战案例分析字符串太长时文本变小无法自动分页的解决方案
136 0
|
PHP
PHP:laravel自定义分页page查询方法
PHP:laravel自定义分页page查询方法
89 0
|
PHP
【PHP】利用array_slice对数组进行分页
【PHP】利用array_slice对数组进行分页
157 0
【PHP】利用array_slice对数组进行分页
|
SQL 关系型数据库 MySQL
|
PHP SQL
php分页数据最后一页继续追加第一页数据
之前做数据分页遇到这样一个需求,就是数据到最后一页的时候不能中断,继续把第一页的数据追加到后面,无限显示下去。 原文地址:代码汇个人博客 http://www.codehui.net/info/23.
1012 0