在PHP代码中使用MongoDB的aggregate()
函数时出现以下错误。此代码完全适用于运行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
代码
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)
));
}
环境
答案 0 :(得分:0)