limit() Query in Codeigniter

Codeigniter provides a limit() method clause that is used to specify the number of records to return.

The limit() method makes it easy to code multi page results or pagination with SQL, and is very useful on large tables. Returning a large number of records can impact on performance.

Lets you limit the number of rows you would like returned by the query

$this->db->limit(15);  // Produces: LIMIT 15

The second parameter lets you set a result offset.

$this->db->limit(10, 20);  
// Produces: LIMIT 20, 10 

Leave a Reply

Your email address will not be published. Required fields are marked *