|
MongoCollection::distinctRetrieve a list of distinct values for the given key across a collection. Description
public array MongoCollection::distinct
( string
$key
[, array $query
] )The distinct command returns a list of distinct values for the given key across a collection. Parameters
Return Values
Returns an array of distinct values, or ExamplesExample #1 MongoCollection::distinct example
<?php The above example will output: array(2) { [0]=> int(10010) [1]=> int(99701) } array(1) { [0]=> int(10010) } array(2) { [0]=> int(10010) [1]=> int(99701) } Example #2 MongoCollection::distinct example on a embedded document
<?php The above example will output: array(2) { [0]=> int(25) [1]=> int(31) } array(0) { } |