(PECL mongo >=1.2.11)
MongoCollection::distinct — ��ȡ������ָ�����IJ�ֵͬ���б�
$key
[, array $query
] ) : arraydistinct ����ؼ������������ֵͬ���б�
key
Ҫʹ�õļ���
query
һ����ѡ�IJ�ѯ����
���ز�ֵͬ�����飬 ������ʧ��ʱ���� FALSE
Example #1 MongoCollection::distinct() ����
<?php
$m = new Mongo;
$db = $m->selectDB("test");
$db->dropCollection("distinct");
$c = $db->distinct;
$c->insert(array("stuff" => "bar", "zip-code" => 10010));
$c->insert(array("stuff" => "foo", "zip-code" => 10010));
$c->insert(array("stuff" => "bar", "zip-code" => 99701), array("w" => 1));
$retval = $c->distinct("zip-code");
var_dump($retval);
$retval = $c->distinct("zip-code", array("stuff" => "foo"));
var_dump($retval);
$retval = $c->distinct("zip-code", array("stuff" => "bar"));
var_dump($retval);
?>
�������̻������
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() ����
<?php
$c->insert(array("user" => array("points" => 25)));
$c->insert(array("user" => array("points" => 31)));
$c->insert(array("user" => array("points" => 25)));
$retval = $c->distinct("user.points");
var_dump($retval);
$retval = $c->distinct("user.nonexisting");
var_dump($retval);
?>
�������̻������
array(2) { [0]=> int(25) [1]=> int(31) } array(0) { }