From b290e3e418fb4c634b1f7ed862a6b8f8736e61d6 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 15 Nov 2011 13:07:47 +0000 Subject: [PATCH] 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 --- reference/mongo/mongodb/command.xml | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/reference/mongo/mongodb/command.xml b/reference/mongo/mongodb/command.xml index 9ddc692f87..f7dc761ca3 100644 --- a/reference/mongo/mongodb/command.xml +++ b/reference/mongo/mongodb/command.xml @@ -139,6 +139,44 @@ foreach ($ages['values'] as $age) { 4 22 +87 + + + + <function>MongoDB::command</function> "distinct" example + + Finding all of the distinct values for a key, where the value is larger + than or equal to 18. + + +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"; +} + +?> +]]> + + &example.outputs.similar; + +22 87