PHPWales 2020 - June 3rd to June 4th

MongoCursor::limit

(PECL mongo >=0.9.0)

MongoCursor::limitLimits the number of results returned

Description

public MongoCursor::limit ( int $num ) : MongoCursor

Parameters

num

The number of results to return.

Return Values

Returns this cursor.

Errors/Exceptions

Throws MongoCursorException if this cursor has started iterating.

See Also

add a note add a note

User Contributed Notes 1 note

up
0
vinicius at codemakers dot com dot br
5 years ago
//Show only unique result

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