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. CodeForce---Educational Codeforces Round 3 D. Gadgets for dollars and pounds 正题

    对于这题笔者无解,只有手抄一份正解过来了: 基本思想就是 : 二分答案,对于第x天,计算它最少的花费f(x),<=s就是可行的,这是一个单调的函数,所以可以二分. 对于f(x)的计算,我用了nl ...

  2. 瞬间从IT屌丝变大神——注释规则

    注释的主要规则如下: 公共组件和各栏目的维护者都需要在文件头部加上注释说明: /** *文件用途说明 *作者姓名 *联系方式*制作日期 **/ 大的模块注释方法: //======= //代码用途 / ...

  3. [算法] 冒泡排序 Bubble Sort

    冒泡排序(Bubble Sort,台湾另外一种译名为:泡沫排序)是一种简单的排序算法.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地进行直到没 ...

  4. 【转】linux shell 正则表达式(BREs,EREs,PREs)差异比较

    我想各位也和我一样,再linux下使用grep,egrep, awk , sed, vi的搜索时,会经常搞不太清楚,哪此特殊字符得使用转义字符'\' ..   哪些不需要, grep与egrep的差异 ...

  5. java开发者最常去的20个英文网站

    java开发者最常去的20个英文网站: 1.[http://www.javaalmanac.com] Java开发者年鉴一书的在线版本. 要想快速查到某种Java技巧的用法及示例代码, 这是一个不错的 ...

  6. trate

    from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text imp ...

  7. Android与Mysql服务器通信

    需求:在手机端读取蓝牙传输过来的数据,然后发送到mysql 安卓前期版本可以直接使用mysql connector, 现在只能通过访问url传递数据了. 服务器端写php脚本,接受发送过来的url请求 ...

  8. jemalloc优化MySQL、Nginx内存管理

    上一篇文章<TCMalloc优化MySQL.Nginx.Redis内存管理>,下面来看下jemalloc jemalloc源于Jason Evans 2006年在BSDcan confer ...

  9. Hibernate之Session对象的相关方法以及持久化对象的状态

    一.持久化对象的状态        站在持久化的角度, Hibernate 把对象分为 4种状态: 持久化状态,临时状态,游离状态,删除状态.Session 的特定方法能使对象从一个状态转换到另一个状 ...

  10. Configure the handler mapping priority in Spring MVC

    Often times, you may mix use of multiple handler mappings strategy in Spring MVC development. For ex ...