选择语言 :

Core_Pagination

分页核心类

使用方法举例

 # 配置默认值见 pagination.config.php 配置

 $pageconfig = array
 (
     'source'         => 'default',                //可不设置,默认值:default,可选query_string,route和default
     'key'            => '0',                      //指定参数位置,通常source为default时,key都为0,若source为query_string或route时,通常为page
     'items_per_page' => 20,                       //可不设置,默认值20
     'view'           => 'pagination/basic',       //可不设置,默认值pagination/basic
     'auto_hide'      => true,                    //可不设置,默认值true
 );

若不设置,则全为默认值,例如:$pagination = new Pagination();

  $pagination = new Pagination($pageconfig);
  $offset     = $pagination->offset();
  $limit      = $pagination->items_per_page();

通过$offset和$limit获取指定分页数据

  $data = Database::instance()->limit($limit, $offset)->get()->as_array();

API - Core_Pagination

author
呼吸二氧化碳 jonwang@myqee.com
category
MyQEE
package
System
subpackage
Core
copyright
Copyright © 2008-2013 myqee.com
license
http://www.myqee.com/license.html

Pagination::factory( $config = 'default')

返回一个实例化对象的分页类

参数列表

参数 类型 描述 默认值
$config string | array configuration string(7) "default"
返回值
  • Pagination

$this->__construct( $config = 'default')

实例化对象

参数列表

参数 类型 描述 默认值
$config array Configuration string(7) "default"
返回值
  • void

$this->renew( )

设置更新

返回值
  • object Pagination

$this->url( $page = 1)

获取指定分页数的URL

 $page = new Pagination();
 echo $page->total_items(100)->url(10);

参数列表

参数 类型 描述 默认值
$page integer Page number integer 1
返回值
  • string page URL

$this->valid_page( $page )

检查当前分页数是否存在

参数列表

参数 类型 描述 默认值
$page integer Page number
返回值
  • boolean

$this->render( $view = null)

返回分页HTML

参数列表

参数 类型 描述 默认值
$view $view 视图对象或视图文件名 null
返回值
  • string 分页HTML

$this->current_page( )

获取,设置当前页

返回值
  • int

$this->total_items( )

获取,设置总数

返回值
  • int

$this->items_per_page( )

获取,设置每页项目数

返回值
  • int

$this->total_pages( )

获取总页数

返回值
  • int

$this->current_first_item( )

获取当前页第一个项目

返回值
  • int

$this->current_last_item( )

获取当前页最后一个项目

返回值
  • int

$this->previous_page( )

获取上一页页码

如果当前是第一页,则返回false

返回值
  • int

$this->next_page( )

获取下一页页码

如果当前是最后一页,则返回false

返回值
  • int
  • false 表示已经没有下一页了

$this->first_page( )

获取第一页页码

返回值
  • int

$this->last_page( )

获取最后一页页码

返回值
  • int

$this->offset( )

获取页码Offset值

返回值
  • int

$this->get_or_set_data( $key , $value = null)

获取或读取数据

参数列表

参数 类型 描述 默认值
$key string $key
$value int $value null
返回值
  • Pagination

$this->__toString( )

输出HTML

返回值
  • string pagination output (HTML)

$this->__get( $key )

Returns a Pagination property.

参数列表

参数 类型 描述 默认值
$key string URI of the request
返回值
  • mixed Pagination property; null if not found

$this->__set( $key , $value )

Updates a single config setting, and recalculates pagination if needed.

参数列表

参数 类型 描述 默认值
$key string Config key
$value mixed Config value
返回值
  • void