-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestmr.php
45 lines (23 loc) · 784 Bytes
/
testmr.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
include_once('Config.php')
// construct map and reduce functions
$map =new MongoCode("function() { emit($pro->TempAdminBill(array('customer')),$pro->AdminOrder(array('price')); }");
$reduce = new MongoCode("function(k, vals) { ".
"var sum = 0;".
"for (var i in vals) {".
"sum += vals[i];".
"}".
"return sum; }");
db.order.mapReduce(mapFunction1, reduceFunction1, {query: {status: "A" },
out: "order_totals"});
$sales = $pro->command(array(
,
"map" => $map,
"reduce" => $reduce,
"query" => array("" => "sale"),
"out" => array("merge" => "eventCounts")));
$users = $db->selectCollection($sales['result'])->find();
foreach ($users as $user) {
echo "{$user['_id']} had {$user['value']} sale(s).\n";
}
?>