参考文档 : http://php.net/manual/zh/mongocollection.aggregate.php
tinkphp field没有封装关于mogno的sum用法 ;
所以只能借助与原生的mongoCollection::aggregate();
备注:
如果不分组获取统计值,那么只是需要将 _id的数值白变成null
public function statCallLog($where) { $pipeline = [ ['$match' => $where], ['$group' => [ '_id' => '$cid', '新字段名' => [ '$sum' => '$统计的字段的名字' ], ]] ]; $stat_data = $this ->getCollection() ->aggregate($pipeline); return $stat_data; }