Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17977 программистов и 1565 роботов. Сейчас ищут 1822 программиста ...
->limit()
Вернуться к: DB_DataObject
->limit()
->limit() – Set limit
Synopsis
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.
Parameter
-
int $from - limit start (or number), or blank to reset
-
int $number - limit results to number
Note
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.
Example
Setting the Limit
<?php
$person = new DataObjects_Person;
$person->limit(2);
$person->find();
while ($person->fetch()) {
echo "{$person->id} {$person->name}<BR>";
}
$person = new DataObjects_Person;
$person->limit(2,4);
$person->find();
while ($person->fetch()) {
echo "{$person->id} {$person->name}<BR>";
}
?>
Resulting SQL
SELECT * FROM person LIMIT 2
SELECT * FROM person LIMIT 2,4
Вернуться к: DB_DataObject