|  |  |  | 
|---|
|  |  |  | $query = $this->_parseId($query); | 
|---|
|  |  |  | // 结果集偏历 | 
|---|
|  |  |  | $cursor  = $col->find($query,$fields); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 排序 | 
|---|
|  |  |  | if($sort){ | 
|---|
|  |  |  | $cursor->sort($sort); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 聚合 | 
|---|
|  |  |  | * @param  [type] $colName [description] | 
|---|
|  |  |  | * @param  [type] $params  [description] | 
|---|
|  |  |  | * @return [type]          [description] | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public function aggregate($colName, $params){ | 
|---|
|  |  |  | $col = $this->_getCol($colName); | 
|---|
|  |  |  | // 自动处理 '_id' 字段 | 
|---|
|  |  |  | //$query = $this->_parseId($query); | 
|---|
|  |  |  | $result = $col->aggregate($params); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return $result['result']; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 返回最后的错误信息 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return array | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return $arr; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }//End Class | 
|---|
|  |  |  | ?> | 
|---|