代码如图,
$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);