Limit Method

Limit Method is part of database class builder for limiting query result.

It will produce same as SELECT * FROM table WHERE 1 LIMIT [A],[B].

This method suitable for creating pagination with datatable method.


Limit method has 2 required parameters that is offset and count.

$this->db->limit(int $offset, int $count): dbObject


Offset can be zero or positive integer for specifying the offset of the first row to be returned.


Count can be zero or positive integer for specifying the maximum number of rows to be returned.

Example usage

Here is the examples using limit method. See the first of this page for full example.

Basic Usage

For example we assumed want to filter new data in blog table. First, in the model:

class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';
  public function __construct(){
  public function latest(){
    return $this->db->get();
  public function latest3ExceptOne(){
    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

Model::order_by Model::get