thinkphp3.2 mongo扩展 class bug

浏览:433 发布日期:2016/05/26 分类:技术分享 关键字: mongodb thinkphp3.2

[b][/b]


代码如图,
$query = $this->parseWhere(isset($options['where'])?$options['where']:array());
if($this->config['debug']) {
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.group({key:'.json_encode($keys).',cond:'.
json_encode($options['condition']) . ',reduce:' .
json_encode($reduce).',initial:'.
json_encode($initial).'})';
}
try{
$this->debug(true);
$option = array('condition'=>$options['condition'], 'finalize'=>$options['finalize'], 'maxTimeMS'=>$options['maxTimeMS']);
$group = $this->_collection->group($keys,$initial,$reduce,$options);
$this->debug(false);

if($cache && $group['ok'])
S($key,$group,$cache['expire'],$cache['type']);

return $group;
} catch (\MongoCursorException $e) {
E($e->getMessage());
}
bug1.因为在MongoModel.class.php里已经把筛选条件都合并到$option['condition']了,所以这里应该改为
$query = $this->parseWhere(isset($options['condition'])?$options['condition']:array());

bug2.$this->queryStr组装时应该json_encode($query)而不是
bug3. $group = $this->_collection->group($keys,$initial,$reduce,$options);应该改为
$group = $this->_collection->group($keys,$initial,$reduce,$query);

附件 2.jpg ( 150.68 KB 下载:0 次 )

最佳答案
评论( 相关
后面还有条评论,点击查看>>