Just issue command and set distinct key.
Take a look at the following example from the docs:
Search for all the different values ββfor a key.
<?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"; } ?>
In the above example, something similar to:
4 22 87
alexn Mar 08 '11 at 17:40 2011-03-08 17:40
source share