温馨提示:本文共985个字,读完预计3分钟。
$match = [
'$match' => [
'created_at'=>[
'$gte'=>$strstarttime,
'$lt'=>$strendtime
],
]
];
$issuesrescount = Issue::getCollection()->aggregate([
$match,
[
'$group'=>[
'_id'=>[‘raise_org’=>’$raise_org’],
'count'=>[
'$sum'=>1
]
],
]
]);
$itemcount = $issuesrescount[0][‘count’];
$issuesres = Issue::getCollection()->aggregate([
$match,
[
'$group'=>[
'_id'=>[‘raise_org’=>’$raise_org’], //通过user_id分组去重
'product'=>[
'$push'=>'$product'
],
'qtype'=>[
'$push'=>'$qtype'
],
'count'=>[
'$sum'=>1
],
],
],
[‘$skip’=>(int)($page-1)*$pagesize],
[‘$limit’=>(int)$pagesize],
[
'$sort'=>[
'count'=>-1
]
]
]);
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_40613168/article/details/108126263