文字

MongoCursor::limit

(PECL mongo >=0.9.0)

MongoCursor::limitLimits the number of results returned

说明

public MongoCursor MongoCursor::limit ( int $num )

参数

num

The number of results to return.

返回值

Returns this cursor.

错误/异常

Throws MongoCursorException if this cursor has started iterating.

参见

  • MongoDB core docs on » limit.
  • MongoCursor::batchSize() - Limits the number of elements returned in one batch.
  • MongoCursor::skip() - Skips a number of results

用户评论:

[#1] vinicius at codemakers dot com dot br [2013-12-24 14:49:56]

//Show only unique result

$cursor = $collection->find();
$cursor->limit(1);

上一篇: 下一篇: