Helpers\Pagination

Break recordset into a series of pages.

First create a new instance of the class pass in the number of items per page and the instance identifier, this is used for the GET parameter such as ?p=2

The setTotal method expects the total number of records, either set this or pass in a call to a model that will return records then count them on return.

The method used to get the records will need a getLimit passed to it, this will then return the set number of records for that page.

Lastly a method called page_links will return the page links.

The model that uses the limit will need to expect the limit:

public function getContacts($limit)
{
return $this->db->select('
SELECT
*,
(SELECT count(id) FROM '.PREFIX.'contacts) as total
FROM '.PREFIX.'contacts '.$limit);
}

Pagination concept

//create a new object
$pages = new Paginator('1', 'p'); //calling a method to get the records with the limit set (model would be the var holding the model data)
$data['records'] = $this->model->getContacts($pages->getLimit()); //set the total records, calling a method to get the number of records from a model
$pages->setTotal($data['records'][0]->total); //create the nav menu
$data['pageLinks'] = $pages->pageLinks();

Usage example:

$pages = new Paginator('50','p');
$data['records'] = $this->model->getContacts($pages->getLimit());
$pages->setTotal($data['records'][0]->total);
$data['pageLinks'] = $pages->pageLinks();

Helpers\Pagination的更多相关文章

  1. ASP.NET Core 中文文档 第四章 MVC(3.6.1 )Tag Helpers 介绍

    原文:Introduction to Tag Helpers 作者:Rick Anderson 翻译:刘浩杨 校对:高嵩(Jack) 什么是 Tag Helpers? Tag Helpers 提供了什 ...

  2. ASP.NET Core 中文文档 第四章 MVC(3.6.2 )自定义标签辅助类(Tag Helpers)

    原文:Authoring Tag Helpers 作者:Rick Anderson 翻译:张海龙(jiechen) 校对:许登洋(Seay) 示例代码查看与下载 从 Tag Helper 讲起 本篇教 ...

  3. [asp.net core]定义Tag Helpers

    原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring Getting started wi ...

  4. [asp.net core] Tag Helpers 简介(转)

    原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro What are Tag Helpers? ...

  5. pagination 分页

    <!DOCTYPE html> <html> <head> <title>pagination</title> <style type ...

  6. salesforce 零基础学习(四十九)自定义列表分页之使用Pagination实现分页效果 ※※※

    上篇内容为Pagination基类的封装,此篇接上篇内容描述如何调用Pagination基类. 首先先创建一个sObject,起名Company info,此object字段信息如下: 为了国际化考虑 ...

  7. salesforce 零基础学习(四十八)自定义列表分页之Pagination基类封装 ※※※

    我们知道,salesforce中系统标准列表页面提供了相应的分页功能,如果要使用其分页功能,可以访问http://www.cnblogs.com/zero-zyq/p/5343287.html查看相关 ...

  8. knockoutjs+ jquery pagination+asp.net web Api 实现无刷新列表页

    Knockoutjs 是一个微软前雇员开发的前端MVVM JS框架, 具体信息参考官网 http://knockoutjs.com/ Web API数据准备: 偷个懒数据结构和数据copy自官网实例  ...

  9. Handlebars块级Helpers

    1.Handlebars简单介绍: Handlebars是JavaScript一个语义模板库,通过对view和data的分离来快速构建Web模板.它采用"Logic-less templat ...

随机推荐

  1. JS代码的简单重构与优化(适合新手)

    Demo . 1 //bad if (age > 20) { return true; } else { return false; } //good return age > 20; 这 ...

  2. 你今天Python了吗?(上)

    你今天Python了吗?为了提高你的生产效率,赶快去关注一下小蟒蛇的成长吧!别再把Python当作你的业余爱好了,她能为你做手头上几乎所有的工作,而且能做得更好,也让你把写代码看成是一种真正的乐趣.为 ...

  3. PHP中我经常容易混淆的三组函数

    原文:http://www.ido321.com/1252.html 一.htmlentities() 和htmlspecialchars() 1.htmlentities() 1.1  功能:把字符 ...

  4. 写i2c_client驱动的两种方式

    http://www.cnblogs.com/simonshi/archive/2011/02/24/1963426.html

  5. 线性方法用于Binary clssification

    到现在,我们已经学过三种线性方法:linear classification.Linear Regression.logistic Regression.这三种方法的核心都是,不同点在于:最小化的er ...

  6. 微信公众平台开发(57)Emoji表情符号

    微信公众平台开发 微信公众平台开发模式 企业微信公众平台 Emoji表情符号 作者:方倍工作室 地址:http://www.cnblogs.com/txw1958/p/crack-golden-egg ...

  7. 内核源码分析之linux内核栈(基于3.16-rc4)

    在3.16-rc4内核源码中,内核给每个进程分配的内核栈大小为8KB.这个内核栈被称为异常栈,在进程的内核空间运行时或者执行异常处理程序时,使用的都是异常栈,看下异常栈的代码(include/linu ...

  8. spring-boot系列:初试spring-boot

    部署父工程 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http: ...

  9. struts2+Hibernate4+spring3+EasyUI环境搭建之四:引入hibernate4以及spring3与hibernate4整合

    1.导入hibernate4 jar包:注意之前引入的struts2需要排除javassist  否则冲突 <!-- hibernate4 --> <dependency> & ...

  10. 使用truss、strace或ltrace诊断软件的“疑难杂症”

    简介 进程无法启动,软件运行速度突然变慢,程序的"Segment Fault"等等都是让每个Unix系统用户头痛的问题,本文通过三个实际案例演示如何使用truss.strace和l ...