Page Method

The page method is part of database class builder for limiting query result.

Basic Usage

Here is the basic usage page method from $db property on SENE_Model class.

$this->db->page(int $page, int $pagesize): $this->db

Parameters

This method has 2 required parameters.

$page

The $page value is for determine the current page of specified pagesize.

$pagesize

The $pagesize the maximum result row count per page.

Example

On this example will show limiting the result query by using page method in model class.

<?php
class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';
  public function __construct(){
    parent::__construct();
  }
  public function showFirstPagePer5Rows(){
    $this->db->select("*");
    $this->db->from($this->tbl,$this->tbl_as);
    $this->db->order_by("date_create","desc");
    $this->db->page(1,5);
    return $this->db->get();
  }
}

Page method v.s. Limit Method

Page method used for limiting by page and page size.

Limit method used for limiting data by MySQL traditional limit method.