使用MongoHQ在Heroku PHP中未定义MongoCollection :: aggregate() [英] MongoCollection::aggregate() is undefined in Heroku PHP using MongoHQ

查看:142
本文介绍了使用MongoHQ在Heroku PHP中未定义MongoCollection :: aggregate()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP代码中使用MongoDB的aggregate()函数时,出现以下错误.这段代码完全可以在运行MongoDB 2.2.3的本地设置上正常工作

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

代码

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)
                                    ));
}

环境

  • Heroku上的PHP
  • 带有MongoHQ附加组件的MongoDB 2.2.4

推荐答案

您必须查看您的phpinfo()

如果在该版本中您看到的内容少于1.3.0,则它将无法正常工作.

If in the version you see something less than 1.3.0, then it will not work.

转到 mongo驱动程序页面下载并添加适当的驱动程序. 重新启动服务器,它将正常工作.

Go to mongo driver page download and add appropriate driver. Restart the server and it will work.

这篇关于使用MongoHQ在Heroku PHP中未定义MongoCollection :: aggregate()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆