Added another example to show that you can also pass in a query with distinct.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@319248 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Derick Rethans 2011-11-15 13:07:47 +00:00
parent e88ead0c09
commit b290e3e418

View file

@ -139,6 +139,44 @@ foreach ($ages['values'] as $age) {
<screen>
4
22
87
</screen>
</example>
<example>
<title><function>MongoDB::command</function> "distinct" example</title>
<para>
Finding all of the distinct values for a key, where the value is larger
than or equal to 18.
</para>
<programlisting role="php">
<![CDATA[
<?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",
"query" => array("age" => array('$gte' => 18))
)
);
foreach ($ages['values'] as $age) {
echo "$age\n";
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
22
87
</screen>
</example>