当前位置: 首页>>代码示例>>PHP>>正文


PHP MongoCollection::aggregateCursor方法代码示例

本文整理汇总了PHP中MongoCollection::aggregateCursor方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCollection::aggregateCursor方法的具体用法?PHP MongoCollection::aggregateCursor怎么用?PHP MongoCollection::aggregateCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCollection的用法示例。


在下文中一共展示了MongoCollection::aggregateCursor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mkonereg

function mkonereg($db, $colname, $grouparr)
{
    $ops = array();
    //  $ops[] = ['$match' => $query];
    //  $ops[] = ['$sort' => ['year'=> -1, 'month'=> -1]];
    $ops[] = ['$group' => $grouparr];
    $option = ['allowDiskUse' => true];
    //print_r($ops);
    $collection = new MongoCollection($db, $colname);
    echo "working on: {$colname} ... with";
    $col2name = $colname . "_reg";
    $col2 = new MongoCollection($db, $col2name);
    print_r($grouparr['_id']);
    makegrpIndex($db, $col2, $grouparr['_id']);
    //print_r($ops);
    try {
        $cursor = $collection->aggregateCursor($ops, $option);
    } catch (MongoException $e) {
        echo "error message: " . $e->getMessage() . "\n";
        echo "error code: " . $e->getCode() . "\n";
        exit(1);
    }
    //$results = $cursor['result'];
    foreach ($cursor as $result) {
        //print_r($result[_id]);
        $col2->insert($result['_id']);
    }
}
开发者ID:hunkim,项目名称:kproperty,代码行数:28,代码来源:mkregions.php

示例2: down

 /**
  * Convert foreign id values from MongoId to string.
  *
  * @return void
  */
 public function down()
 {
     // The Client model has a mutator that converts lrs_id from string to MongoId,
     // so the Mongo classes are used to directly modify the client collection.
     $db = \DB::getMongoDB();
     $clients = new MongoCollection($db, 'client');
     $lrsIds = $clients->aggregateCursor([['$group' => ['_id' => '$lrs_id']]]);
     foreach ($lrsIds as $lrsId) {
         $clients->update(['lrs_id' => $lrsId['_id']], ['$set' => ['lrs_id' => (string) $lrsId['_id']]], ['multiple' => true]);
     }
     echo 'Foreign id values in client collection converted from MongoId to string.' . PHP_EOL;
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:17,代码来源:2015_09_15_075532_client_foreign_ids.php

示例3: findMostReportedCommentary

 /**
  * Retrieves an iterator on a list of abusive Commentary
  *
  * @param int $offset
  * @param int $limit
  *
  * @return \MongoCursor
  */
 public function findMostReportedCommentary($offset = 0, $limit = 20)
 {
     return $this->collection->aggregateCursor([['$match' => ['commentary.0' => ['$exists' => true], 'commentary' => ['$elemMatch' => ['abusiveCount' => ['$gt' => 0]]]]], ['$unwind' => '$commentary'], ['$match' => ['commentary.abusiveCount' => ['$gt' => 0]]], ['$project' => ['commentary' => true]], ['$sort' => ['commentary.abusiveCount' => -1]]]);
     // I love arrays
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:13,代码来源:AbuseReport.php


注:本文中的MongoCollection::aggregateCursor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。