2011-03-08 5 views

답변

4

command을 발급하고 distinct 키를 설정하십시오.

는 문서에서 다음의 예를 살펴 보자 :

키의 고유 값을 모두 찾기.

<?php 

$people = $db->people; 

$people->insert(array("name" => "Joe", "age" => 4)); 
$people->insert(array("name" => "Sally", "age" => 22)); 
$people->insert(array("name" => "Dave", "age" => 22)); 
$people->insert(array("name" => "Molly", "age" => 87)); 

$ages = $db->command(array("distinct" => "people", "key" => "age")); 

foreach ($ages['values'] as $age) { 
    echo "$age\n"; 
} 

?> 

위 예제의 출력 :

4 
22 
87 
+1

을 "WHERE"절 주소 지정 – monofonik

4

당신이 절은 다음 구문을 사용 어디를 추가해야하는 경우 :이 답변은 '아무튼

$ages = $db->command(array(
    "distinct" => "people", 
    "key" => "age", 
    "query" => array("someField" => "someValue"))); 
관련 문제