最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Codeigniter MongoDB扩展之使用Aggregate实现Sum方法
时间:2022-06-25 00:50:25 编辑:袖梨 来源:一聚教程网
以下就是我在使用 Codeigniter 的 MongoDB 扩展时,添加的一个扩展
就是使用 MongoDB 的 Aggregate 实现 Mysql 中的 Sum 方法
/* Controller.php */
$option = array (
array (
'$match' => array (
'match_1' => 'value_1',
'match_2' => 'value_2'
)
),
array (
'$group' => array (
'_id' => null,
'sum_1' => ['$sum' => '$amount_1'],
'sum_2' => ['$sum' => '$amount_2'],
'sum_3' => ['$sum' => '$amount_3']
)
)
);
$result = $this -> mongo_db -> aggregate('collection', $option);
/* Mongo_db.php */
public function aggregate ($collection, $option = array())
{
try {
return $this -> db -> {$collection} -> aggregate($option);
}
catch (Exception $e) {
show_error("Unable to aggregate Mongo Databases: {$e->getMessage()}", 500);
}
}
相关文章
- 哔咔漫画官方下载入口安卓版安装-哔咔漫画下载2024最新版本安装包 02-16
- 樱花动漫下载app安卓苹果最新版-樱花动漫手机客户端官方正版下载入口 02-16
- 钮祜禄梗是什么-钮祜禄梗的出处 02-16
- 妖精动漫网页版登录-妖精动漫官网一键登录 02-16
- 医学考试网官网入口-2026医师资格成绩查询入口 02-16
- 百度答题金手指入口不见了怎么进入-百度答题金手指玩法技巧 02-16