PHP 7.0.6 Released

MongoCursor::limit

(PECL mongo >=0.9.0)

MongoCursor::limitLimits the number of results returned

Description

public MongoCursor MongoCursor::limit ( int $num )

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

User Contributed Notes

vinicius at codemakers dot com dot br
2 years ago
//Show only unique result

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