本篇文章由:http://xinpure.com/codeigniter-mongodb-extension-using-aggregate-sum-method/

Codeigniter MongoDB扩展之使用Aggregate实现Sum方法

以下就是我在使用 CodeigniterMongoDB 扩展时,添加的一个扩展
就是使用 MongoDBAggregate 实现 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);
}
}

最新文章

  1. 【JUC】JDK1.8源码分析之CountDownLatch(五)
  2. php识别中文编码并自动转换为UTF-8
  3. 用wireshark抓包分析TCP三次握手、四次挥手以及TCP实现可靠传输的机制
  4. BZOJ1727 [Usaco2006 Open]The Milk Queue 挤奶队列
  5. 小巧的http live streaming m3u8播放器
  6. eclipse提交本地项目到github
  7. Microsoft Visual C++ 不支持long long
  8. HTML form表单回车触发提交
  9. epoll 实现回射服务器
  10. 【win7】安装php7.3及扩展
  11. 判断是手机请求还是pc请求
  12. Codeforces 893A:Chess For Three(模拟)
  13. python 数据类型 之 字符串 拼接 方法 以及效率问题
  14. Where To Buy -- proposed by Renqian Luo
  15. 前端内容安全策略(csp)
  16. Python Flask 多环境配置
  17. poj1836 Alignment
  18. Unhandled rejection RangeError: Maximum call stack size exceededill install loadIdealTree
  19. Android 数据加密算法 Des,Base64详解
  20. 201621123023《Java程序设计》第12周学习总结

热门文章

  1. [BZOJ2216]Lightning Conductor
  2. 【Splay】bzoj3223 Tyvj 1729 文艺平衡树
  3. 【后缀自动机】CDOJ1551 Hesty Str1ng
  4. 【带权并查集】poj1182 食物链
  5. Mobiscroll手机触屏日期选择器
  6. 使用create-react-app时的something is already running on port 3000
  7. Unity3D 粒子系统
  8. iOS 自定义对象及子类及模型套模型的拷贝、归档存储的通用代码
  9. 安装Ubuntu Linux分区的推荐方案和方法
  10. 关于DeploymentConfig的思考