php操作mongodb 分组排序
1 //连接mongodb2
3 $db=db("127.0.0.1","27017","db_name");
4
5 //定义临时表和变量
6
7 $temptable="temp_softdownrank";
8
9 $softid="1";
10
11 $softname="a";
12 //删除临时表
13 $mdret=$db->$temptable->drop();
14
15 if($mdret)
16 {
17 //map/reduce 做分组排序
18
19 //要查询的列 用emit生成key=>value进行存储
20
21 $map = new MongoCode("function() { emit(this.softid, {count: 1, softid: this.softid, softname: this.softname}); }");
22
23 //要生成的列
24 $reduce = new MongoCode(
25 "function(key, value) {
26 var result = {count: 0};
27 for(var i=0; i
页:
[1]