我使用的是带有两个分片集群配置的MongoDB 2.6。我想调用我创建并存储在MongoDB中的函数dataStats()。这是我的PHP脚本:
$client = new Mongo();
$db = $client->mydata;
$db->system->js->save(array("_id"=>"dataStats",
"value"=>new MongoCode("function() { ... }")));
$db->execute("dataStats()");这段代码给出了这个错误:
'err' => 'Error: can\'t use sharded collection from db.eval',
'code' => 16722原因是$db->execute方法使用的是Mongo db.eval command which is not supported with sharded collections。是否有解决此问题的方法?我们如何在PHP中调用分片MongoDB中的存储过程?
发布于 2014-11-08 00:09:10
没有变通的方法。db.eval不能处理分片的集合。无论如何,如果可能,你应该避免使用它。
https://stackoverflow.com/questions/26795597
复制相似问题