【发布时间】:2015-12-06 07:30:36
【问题描述】:
我有这样的收藏
{
"wl_total" : 380,
"player_id" : 1241,
"username" : "Robin",
"hand_id" : 292656,
"time" : 1429871584
}
{
"wl_total" : -400,
"player_id" : 1243,
"username" : "a",
"hand_id" : 292656,
"time" : 1429871584
}
由于两个集合具有相同的 hand_id,我想根据 hand_id 聚合这两个集合 我想要的结果是
data=array(
'hand_id'=>292656,
'wl_total'=>
{
0=>380,
1=>-400
},
'username'=>
{
0=>"Robin",
1=>"a"
},
"time"=>1429871584
)
【问题讨论】:
-
那不是数组。这是json。
-
是的,但我想从 db 获取数据,正如我提到的 json 格式
-
所以你的数据库的输出是你问题的首要问题?
-
没有底部“数据”中的第二个,我已将您显示为可读性数组,但实际上输出将在 json 中
-
啊。我知道了。因此,您的问题最重要的是您的预期输出。
标签: php mongodb laravel mongodb-query aggregation-framework