AggregateSumメソッドのCodeigniterMongoDB拡張機能を使用して



Use Codeigniter Mongodb Extension Aggregate Sum Method Achieve



この記事の作成: http://xinpure.com/codeigniter-mongodb-extension-using-aggregate-sum-method/

AggregateSumメソッドのCodeigniterMongoDB拡張機能を使用して

以下は私が使用するものですCodeigniterMongoDB拡張すると、aを追加するために拡張が使用されます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) } }