note 110657 added to mongocollection.group
| From: | ronan dot guilloux at gmail dot com | Date: | Mon, 19 Nov 2012 15:38:15 +0000 |
| Subject: | note 110657 added to mongocollection.group | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192036@lists.php.net to get a copy of this message | ||
Since the $options argument is no longer a scalar (deprecated since the 1.2.11 version of the
Mongo's PHP driver), you now must compose your $options as an associative array, otherwise
you'll rise a "Implicitly passing condition as $options will be removed in the
future" alert.
Example:
<?php
$m = new Mongo();
$db = $m->selectDB('test');
$collection = new MongoCollection($db, 'FooBar');
// grouping results by categories, where foo is 'bar'
$keys = array('categorie'=>true, 'foo'=>true); // the fields list we want
to return
$initial = array('count' => 0); // gets a subtotal for each categorie
$reduce = "function(obj,prev) { prev.count += 1; }"; // yes, this is js code
$conditions = array('foo'=> 'bar');
$grouped = $myColl::group($keys, $initial, $reduce, array('condition'=>$conditions));
$result = $grouped['retval'];
?>
----
Server IP: 195.221.21.36
Probable Submitter: 80.14.55.156
----
Manual Page -- http://www.php.net/manual/en/mongocollection.group.php
Edit -- https://master.php.net/note/edit/110657
Del: integrated -- https://master.php.net/note/delete/110657/integrated
Del: useless -- https://master.php.net/note/delete/110657/useless
Del: bad code -- https://master.php.net/note/delete/110657/bad+code
Del: spam -- https://master.php.net/note/delete/110657/spam
Del: non-english -- https://master.php.net/note/delete/110657/non-english
Del: in docs -- https://master.php.net/note/delete/110657/in+docs
Del: other reasons-- https://master.php.net/note/delete/110657
Reject -- https://master.php.net/note/reject/110657
Search -- https://master.php.net/manage/user-notes.php