->limit() – Set limit


void $DB_DataObject->limit ( int $from , int $number )


Sets the limit for a query. (this only works on databases that support the LIMIT clause), without parameters, it will clear the current limit.


  • int $from - limit start (or number), or blank to reset

  • int $number - limit results to number


This function can not be called statically.

Since postgres and mysql only really support limit directly - calling this on an unsupported database will emit a PEAR::Error and die.


Setting the Limit

= new DataObjects_Person;
while (
$person->fetch()) {
"{$person->id} {$person->name}<BR>";

$person = new DataObjects_Person;

while (
$person->fetch()) {
"{$person->id} {$person->name}<BR>";

Resulting SQL


SELECT * FROM person LIMIT 2,4
Escape a string for use with Like queries (Previous) Add an order by condition (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.