再看thinkphp5分页类使用
之前使用tp5的分页paginate类时只用到了第一个参数,也就是每页显示多少行
今天又仔细看了下手册和paginate类,发现paginate可传入的参数有很多,可以满足更多需求
比如可以指定分页的数据,可以使用重写的分页类等。。。
下面是tp5.1的分页类
/**
* 分页查询
* @access public
* @param int|array $listRows 每页数量 数组表示配置参数
* @param int|bool $simple 是否简洁模式或者总记录数
* @param array $config 配置参数
* page:当前页,
* path:url路径,
* query:url额外参数,
* fragment:url锚点,
* var_page:分页变量,
* list_rows:每页数量
* type:分页类名
* @return \think\Paginator
* @throws DbException
*/
public function paginate($listRows = null, $simple = false, $config = [])
{
if (is_int($simple)) {
$total = $simple;
$simple = false;
} $paginate = Container::get('config')->pull('paginate'); if (is_array($listRows)) {
$config = array_merge($paginate, $listRows);
$listRows = $config['list_rows'];
} else {
$config = array_merge($paginate, $config);
$listRows = $listRows ?: $config['list_rows'];
} /** @var Paginator $class */
$class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
$page = isset($config['page']) ? (int) $config['page'] : call_user_func([
$class,
'getCurrentPage',
], $config['var_page']); $page = $page < 1 ? 1 : $page; $config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']); if (!isset($total) && !$simple) {
$options = $this->getOptions(); unset($this->options['order'], $this->options['limit'], $this->options['page'], $this->options['field']); $bind = $this->bind;
$total = $this->count();
$results = $this->options($options)->bind($bind)->page($page, $listRows)->select();
} elseif ($simple) {
$results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select();
$total = null;
} else {
$results = $this->page($page, $listRows)->select();
} $this->removeOption('limit');
$this->removeOption('page'); return $class::make($results, $listRows, $page, $total, $simple, $config);
}
再看thinkphp5分页类使用的更多相关文章
- python---django中自带分页类使用
请先看在学习tornado时,写的自定义分页类:思路一致: python---自定义分页类 1.基础使用: 后台数据获取: from django.core.paginator import Pagi ...
- 再看Ajax
再回顾Ajax相关的内容,再次梳理学习还是很有必要的,尤其是实际的开发中,ajax更是必不可少,仔细学习以便避免不必要的错误. 文章导读: --1.使用XMLHttpRequest---------- ...
- 再看ftp上传文件
前言 去年在项目中用到ftp上传文件,用FtpWebRequest和FtpWebResponse封装一个帮助类,这个在网上能找到很多,前台使用Uploadify控件,然后在服务器上搭建Ftp服务器,在 ...
- php之分页类代码
/* 思路 1.把地址栏的URL获取 2.分析URL中的query部分--就是?后面传参数的部分 3.query部分分析成数组 4.把数组中的page单元,+1,-1,形成2个新的数组 5.再把新数组 ...
- (转)ThinkPHP使用心得分享-分页类Page的用法
转之--http://www.jb51.net/article/50138.htm ThinkPHP中的Page类在ThinkPHP/Extend/Library/ORG/Util/Page.clas ...
- 将php分页类YII绑定框架,就需要改变风格的基础
分页类http://blog.csdn.net/buyingfei8888/article/details/40260127 在内部组件分页类 文件名和一致 组件是在什么地方被载入进来的?在主配置文件 ...
- PHP通用分页类page.php[仿google分页]
<?php /** ** 通用php分页类.(仿Google样式) ** 只需提供记录总数与每页显示数两个参数.(已附详细使用说明..) ** 无需指定URL,链接由程序生成.方便用于检索结果分 ...
- ThinkPHP5 核心类 Request 远程代码漏洞分析
ThinkPHP5 核心类 Request 远程代码漏洞分析 先说下xdebug+phpstorm审计环境搭建: php.ini添加如下配置,在phpinfo页面验证是否添加成功. [XDebug] ...
- ThinkPHP分页用异步来做,玩转分页类!
具体为什么用异步来做分页我就不多说了! 用异步来做分页,主要还是看分页类怎么玩! 方便管理,还是把Ajax分页作为一个工具来使用: 同样新建工具类: 多次尝试,最终修改好的分页类是这样的:(我自己使用 ...
随机推荐
- rust ownership 系统
### 对象销毁规则 未被使用的函数返回值 被let绑定的值, 在函数末尾销毁,除非被moved ``` let v = obj::new("a"); other_fun(v); ...
- codeforces 622C C. Not Equal on a Segment
C. Not Equal on a Segment time limit per test 1 second memory limit per test 256 megabytes input sta ...
- [原]NYOJ-组合数-32
大学生程序代写 http://acm.nyist.net/JudgeOnline/problem.php?pid=32 /*组合数 时间限制:3000 ms | 内存限制:65535 KB 难度: ...
- Agc019_D Shift and Flip
传送门 题目大意 给定两个长为$n$的$01$串$A,B$,每次操作有三种 将$A$整体向左移动,并将$A_1$放在原来$A_n$的位置上. 将$A$整体向有移动,并将$A_n$放在原来$A_1$的位 ...
- ACM学习历程—BNUOJ3685 Building for UN(构造)
The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have ...
- 洛谷 2312 / bzoj 3751 解方程——取模
题目:https://www.luogu.org/problemnew/show/P2312 https://www.lydsy.com/JudgeOnline/problem.php?id=3751 ...
- 【转】 Pro Android学习笔记(七十):HTTP服务(4):SOAP/JSON/XML、异常
目录(?)[-] SOAP JSON和XMLPullParser Exception处理 文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件,转载须注明出处:http://blog. ...
- 自定义echart tooltip格式
formatter: function (tipData) { return tipData[0].name + '</br>' + '<span style="displ ...
- 【原】spring jar 下载
作者:david_zhang@sh [转载时请以超链接形式标明文章] 链接:http://www.cnblogs.com/david-zhang-index/p/8098965.html 1.进入官网 ...
- C语言学习笔记--接续符和转义符
1.C语言中的接续符 (1)编译器将反斜杠剔除,跟在反斜杠后面的字符自动接续到前一行 (2)在接续单词时,反斜杠之后不能有空格,反斜杠下一行之前也不能有空格 (3)接续符适合在宏定义代码块时使用 #i ...