svn: /phpdoc/en/trunk/reference/mongo/mongodb/ command.xml

From: Date: Tue, 15 Nov 2011 13:07:47 +0000
Subject: svn: /phpdoc/en/trunk/reference/mongo/mongodb/ command.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9037@lists.php.net to get a copy of this message
derick Tue, 15 Nov 2011 13:07:47 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=319248 Log: Added another example to show that you can also pass in a query with distinct. Changed paths: U phpdoc/en/trunk/reference/mongo/mongodb/command.xml Modified: phpdoc/en/trunk/reference/mongo/mongodb/command.xml =================================================================== --- phpdoc/en/trunk/reference/mongo/mongodb/command.xml 2011-11-15 12:46:40 UTC (rev 319247) +++ phpdoc/en/trunk/reference/mongo/mongodb/command.xml 2011-11-15 13:07:47 UTC (rev 319248) @@ -143,6 +143,44 @@ </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> + <example> <title><function>MongoDB::command</function> MapReduce example</title> <para> Get all users with at least on "sale" event, and how many times each

« previous php.doc.cvs (#9037) next »