mysql_xdevapi\CollectionFind
PHP Manual

CollectionFind::limit

(No version information available, might only be in Git)

CollectionFind::limitLimit number of returned documents

说明

public mysql_xdevapi\CollectionFind mysql_xdevapi\CollectionFind::limit ( integer $rows )

Limit the amount of documents returned by the 'find' option by the amount provided as argument

参数

rows

This is the maximum amount of documents that have to be returned by the find operation

返回值

CollectionFind object that can be used for further processing

范例

Example #1 mysql_xdevapi\CollectionFind::limit() example

<?php

//Assuming $coll is a valid Collection object

//Extract only the first 10 documents from the collection
$res $coll->find()->limit(10)->execute();

//Sort the documents on the base of the 'age' field
//and return the first two "oldest" person in the collection
$res $coll->find()->sort('age desc')->limit(2)->execute();

?>

mysql_xdevapi\CollectionFind
PHP Manual