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


PHP Server::executeBulkWrite方法代码示例

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


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

示例1: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return DeleteResult
  */
 public function execute(Server $server)
 {
     $bulk = new Bulk();
     $bulk->delete($this->filter, ['limit' => $this->limit]);
     $writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
     $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
     return new DeleteResult($writeResult);
 }
开发者ID:zivperry,项目名称:mongo-php-library,代码行数:15,代码来源:Delete.php

示例2: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return InsertOneResult
  */
 public function execute(Server $server)
 {
     $bulk = new Bulk();
     $insertedId = $bulk->insert($this->document);
     if ($insertedId === null) {
         // TODO: This may be removed if PHPC-382 is implemented
         $insertedId = is_array($this->document) ? $this->document['_id'] : $this->document->_id;
     }
     $writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
     $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
     return new InsertOneResult($writeResult, $insertedId);
 }
开发者ID:dangcheng,项目名称:mongo-php-library,代码行数:19,代码来源:InsertOne.php

示例3: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return BulkWriteResult
  */
 public function execute(Server $server)
 {
     $bulk = new Bulk(['ordered' => $this->options['ordered']]);
     $insertedIds = [];
     foreach ($this->operations as $i => $operation) {
         $type = key($operation);
         $args = current($operation);
         switch ($type) {
             case self::DELETE_MANY:
             case self::DELETE_ONE:
                 $bulk->delete($args[0], $args[1]);
                 break;
             case self::INSERT_ONE:
                 $insertedId = $bulk->insert($args[0]);
                 if ($insertedId !== null) {
                     $insertedIds[$i] = $insertedId;
                 } else {
                     // TODO: This may be removed if PHPC-382 is implemented
                     $insertedIds[$i] = is_array($args[0]) ? $args[0]['_id'] : $args[0]->_id;
                 }
                 break;
             case self::REPLACE_ONE:
             case self::UPDATE_MANY:
             case self::UPDATE_ONE:
                 $bulk->update($args[0], $args[1], $args[2]);
         }
     }
     $writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
     $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
     return new BulkWriteResult($writeResult, $insertedIds);
 }
开发者ID:dangcheng,项目名称:mongo-php-library,代码行数:38,代码来源:BulkWrite.php

示例4: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return UpdateResult
  */
 public function execute(Server $server)
 {
     $options = array('multi' => $this->options['multi'], 'upsert' => $this->options['upsert']);
     $bulk = new Bulk();
     $bulk->update($this->filter, $this->update, $options);
     $writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
     $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
     return new UpdateResult($writeResult);
 }
开发者ID:pkdevbox,项目名称:mongo-php-library,代码行数:16,代码来源:Update.php

示例5: executeLegacy

 /**
  * Create one or more indexes for the collection by inserting into the
  * "system.indexes" collection (MongoDB <2.6).
  *
  * @param Server $server
  */
 private function executeLegacy(Server $server)
 {
     $bulk = new Bulk(['ordered' => true]);
     foreach ($this->indexes as $index) {
         $bulk->insert($index);
     }
     $server->executeBulkWrite($this->databaseName . '.system.indexes', $bulk, new WriteConcern(1));
 }
开发者ID:sunpaolo,项目名称:slim3Demo,代码行数:14,代码来源:CreateIndexes.php

示例6: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return InsertManyResult
  */
 public function execute(Server $server)
 {
     $bulk = new Bulk(['ordered' => $this->options['ordered']]);
     $insertedIds = [];
     foreach ($this->documents as $i => $document) {
         $insertedId = $bulk->insert($document);
         if ($insertedId !== null) {
             $insertedIds[$i] = $insertedId;
         } else {
             // TODO: This may be removed if PHPC-382 is implemented
             $insertedIds[$i] = is_array($document) ? $document['_id'] : $document->_id;
         }
     }
     $writeConcern = isset($this->options['writeConcern']) ? $this->options['writeConcern'] : null;
     $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $writeConcern);
     return new InsertManyResult($writeResult, $insertedIds);
 }
开发者ID:dangcheng,项目名称:mongo-php-library,代码行数:24,代码来源:InsertMany.php

示例7: executeLegacy

 /**
  * Create one or more indexes for the collection by inserting into the
  * "system.indexes" collection (MongoDB <2.6).
  *
  * @param Server $server
  * @param IndexInput[] $indexes
  */
 private function executeLegacy(Server $server)
 {
     $bulk = new Bulk(true);
     foreach ($this->indexes as $index) {
         $bulk->insert($index);
     }
     $server->executeBulkWrite($this->databaseName . '.system.indexes', $bulk);
 }
开发者ID:Kozzi11,项目名称:mongo-php-library-prototype,代码行数:15,代码来源:CreateIndexes.php


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