再看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分页作为一个工具来使用: 同样新建工具类: 多次尝试,最终修改好的分页类是这样的:(我自己使用 ...
随机推荐
- 【leetcode刷题笔记】Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...
- hdu Digital Square(广搜)
题目:给出n,求出最小的m,满足m^2 % 10^k = n,其中k=0,1,2 http://acm.hdu.edu.cn/showproblem.php?pid=4394 只要有一个x满足条件便 ...
- C#连接solr时提示 java内存异常 (jetty和tomcat哪个更High) java.lang.OutOfMemoryError
C#连接solr时提示 java内存异常 java.lang.OutOfMemoryError 时间:20180130 09:51:13.329,消息:异常消息<?xml version=& ...
- ACM学习历程—HDU 5443 The Water Problem(RMQ)(2015长春网赛1007题)
Problem Description In Land waterless, water is a very limited resource. People always fight for the ...
- Java如何调用dll
-----------------------------前置条件------------------------------------- 1. 首先有testdll.dll 2. 需要testdl ...
- bzoj 4816 数字表格 —— 反演
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4816 推导过程同:http://www.cnblogs.com/zhouzhendong/p ...
- I2C Bus
概述: I²C 是Inter-Integrated Circuit的缩写,发音为"eye-squared cee" or "eye-two-cee" , 它是一 ...
- HDOJ5441(图论中的并查集)
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; ; ; ...
- 【转】 Pro Android学习笔记(五八):Preferences(2):CheckBoxPreference
目录(?)[-] CheckBox Preference xml文件 设备的存贮文件 复合preference 在ListPreference的例子中显示的是单选,如果是多选,可采用CheckBoxP ...
- LVS实战1
(一).NAT模式:NAT模型:地址转换类型,主要是做地址转换,类似于iptables的DNAT类型,它通过多目标地址转换,来实现负载均衡:特点和要求: 1.LVS(Director)上面需要双网卡: ...