I'm getting the following error when using MongoDB's aggregate()
function in a PHP code. This code perfectly works on my local setup which is running MongoDB 2.2.3
PHP Fatal error: Call to undefined method MongoCollection::aggregate() in /app/www/page.php on line 52, referer: http://referrer.url
Code
foreach($cats as $key=>$val){
$cats2[$val['lable']] = $myCollection->aggregate( array(
array('$match' => array('user_id' => $user_id )),
array('$unwind' =>"\$data"),
array('$match' => array('data.category'=> $val['category'])),
array('$project' => array('name'=> "\$data.name", 'id'=>"\$data.id")),
array('$group' => array('_id'=>'$id', 'name'=> array('$first' =>'$name'))),
array('$limit' => 12)
));
}
Environment
- PHP on Heroku
- MongoDB 2.2.4 with MongoHQ Add-on