note 119717 added to class.mongodb-driver-command
| From: | tdrpic | Date: | Tue, 09 Aug 2016 17:28:47 +0000 |
| Subject: | note 119717 added to class.mongodb-driver-command | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206251@lists.php.net to get a copy of this message | ||
In case you're wondering how to perform a 'distinct' query:
<?php
// Sample MongoDB command:
// db.product.distinct("scent", {"prodCat": "10 oz can"})
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = ['prodCat' => '10 oz can']; // your typical MongoDB query
$cmd = new MongoDB\Driver\Command([
// build the 'distinct' command
'distinct' => 'product', // specify the collection name
'key' => 'scent', // specify the field for which we want to get the
distinct values
'query' => $query // criteria to filter documents
]);
$cursor = $manager->executeCommand('catalog', $cmd); // retrieve the results
$scents = current($cursor->toArray())->values; // get the distinct values as an array
var_dump($scents);
?>
----
Server IP: 72.52.91.14
Probable Submitter: 184.183.182.200
----
Manual Page -- http://php.net/manual/en/class.mongodb-driver-command.php
Edit -- https://master.php.net/note/edit/119717
Del: integrated -- https://master.php.net/note/delete/119717/integrated
Del: useless -- https://master.php.net/note/delete/119717/useless
Del: bad code -- https://master.php.net/note/delete/119717/bad+code
Del: spam -- https://master.php.net/note/delete/119717/spam
Del: non-english -- https://master.php.net/note/delete/119717/non-english
Del: in docs -- https://master.php.net/note/delete/119717/in+docs
Del: other reasons-- https://master.php.net/note/delete/119717
Reject -- https://master.php.net/note/reject/119717
Search -- https://master.php.net/manage/user-notes.php