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


PHP Driver\Server类代码示例

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


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

示例1: server_supports_feature

/**
 * Return whether the server supports a particular feature.
 *
 * @internal
 * @param Server  $server  Server to check
 * @param integer $feature Feature constant (i.e. wire protocol version)
 * @return boolean
 */
function server_supports_feature(Server $server, $feature)
{
    $info = $server->getInfo();
    $maxWireVersion = isset($info['maxWireVersion']) ? (int) $info['maxWireVersion'] : 0;
    $minWireVersion = isset($info['minWireVersion']) ? (int) $info['minWireVersion'] : 0;
    return $minWireVersion <= $feature && $maxWireVersion >= $feature;
}
开发者ID:Kozzi11,项目名称:mongo-php-library-prototype,代码行数:15,代码来源:functions.php

示例2: executeLegacy

 /**
  * Returns information for all indexes for this collection by querying the
  * "system.indexes" collection (MongoDB <3.0).
  *
  * @param Server $server
  * @return IndexInfoIteratorIterator
  */
 private function executeLegacy(Server $server)
 {
     $filter = array('ns' => $this->databaseName . '.' . $this->collectionName);
     $options = isset($this->options['maxTimeMS']) ? array('modifiers' => array('$maxTimeMS' => $this->options['maxTimeMS'])) : array();
     $cursor = $server->executeQuery($this->databaseName . '.system.indexes', new Query($filter, $options));
     $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
     return new IndexInfoIteratorIterator($cursor);
 }
开发者ID:Kozzi11,项目名称:mongo-php-library-prototype,代码行数:15,代码来源:ListIndexes.php

示例3: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return array|object Command result document
  */
 public function execute(Server $server)
 {
     $cursor = $server->executeCommand($this->databaseName, new Command(['dropDatabase' => 1]));
     if (isset($this->options['typeMap'])) {
         $cursor->setTypeMap($this->options['typeMap']);
     }
     return current($cursor->toArray());
 }
开发者ID:alcaeus,项目名称:mongo-php-library,代码行数:15,代码来源:DropDatabase.php

示例4: 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

示例5: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return integer
  */
 public function execute(Server $server)
 {
     $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
     $cursor = $server->executeCommand($this->databaseName, $this->command, $readPreference);
     if (isset($this->options['typeMap'])) {
         $cursor->setTypeMap($this->options['typeMap']);
     }
     return $cursor;
 }
开发者ID:roquie,项目名称:mongo-php-library,代码行数:16,代码来源:DatabaseCommand.php

示例6: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return object Command result document
  */
 public function execute(Server $server)
 {
     $cursor = $server->executeCommand($this->databaseName, new Command(array('drop' => $this->collectionName)));
     $result = current($cursor->toArray());
     if (empty($result->ok)) {
         throw new RuntimeException(isset($result->errmsg) ? $result->errmsg : 'Unknown error');
     }
     return $result;
 }
开发者ID:Kozzi11,项目名称:mongo-php-library-prototype,代码行数:16,代码来源:DropCollection.php

示例7: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return array|object Command result document
  */
 public function execute(Server $server)
 {
     $cmd = ['dropIndexes' => $this->collectionName, 'index' => $this->indexName];
     $cursor = $server->executeCommand($this->databaseName, new Command($cmd));
     if (isset($this->options['typeMap'])) {
         $cursor->setTypeMap($this->options['typeMap']);
     }
     return current($cursor->toArray());
 }
开发者ID:sunpaolo,项目名称:slim3Demo,代码行数:16,代码来源:DropIndexes.php

示例8: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return object
  */
 public function execute(Server $server)
 {
     $command = new Command(['group' => ['ns' => $this->collectionName, 'key' => $this->keys, 'initial' => $this->initial, '$reduce' => $this->reduce]]);
     $cursor = $server->executeCommand($this->databaseName, $command);
     // Get first element of iterator
     foreach ($cursor as $result) {
         break;
     }
     return isset($result) ? $result : null;
 }
开发者ID:hardsetting,项目名称:yii2-mongodb,代码行数:17,代码来源:Group.php

示例9: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  *
  * @param Server $server
  *
  * @return mixed[]
  * @throws UnexpectedValueException if the command response was malformed
  */
 public function execute(Server $server)
 {
     $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
     $cursor = $server->executeCommand($this->databaseName, $this->createCommand($server), $readPreference);
     $result = current($cursor->toArray());
     if (!isset($result->values) || !is_array($result->values)) {
         throw new UnexpectedValueException('distinct command did not return a "values" array');
     }
     return $result->values;
 }
开发者ID:phalcon,项目名称:incubator,代码行数:20,代码来源:Distinct.php

示例10: 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

示例11: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return mixed[]
  */
 public function execute(Server $server)
 {
     $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
     $result = current($cursor->toArray());
     if (empty($result->ok)) {
         throw new RuntimeException(isset($result->errmsg) ? $result->errmsg : 'Unknown error');
     }
     if (!isset($result->values) || !is_array($result->values)) {
         throw new UnexpectedValueException('distinct command did not return a "values" array');
     }
     return $result->values;
 }
开发者ID:Kozzi11,项目名称:mongo-php-library-prototype,代码行数:19,代码来源:Distinct.php

示例12: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return integer
  */
 public function execute(Server $server)
 {
     $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
     $result = current($cursor->toArray());
     if (empty($result->ok)) {
         throw new RuntimeException(isset($result->errmsg) ? $result->errmsg : 'Unknown error');
     }
     // Older server versions may return a float
     if (!isset($result->n) || !(is_integer($result->n) || is_float($result->n))) {
         throw new UnexpectedValueException('count command did not return a numeric "n" value');
     }
     return (int) $result->n;
 }
开发者ID:Kozzi11,项目名称:mongo-php-library-prototype,代码行数:20,代码来源:Count.php

示例13: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return object Command result document
  */
 public function execute(Server $server)
 {
     try {
         $cursor = $server->executeCommand($this->databaseName, new Command(['drop' => $this->collectionName]));
     } catch (RuntimeException $e) {
         /* The server may return an error if the collection does not exist.
          * Check for an error message (unfortunately, there isn't a code)
          * and NOP instead of throwing.
          */
         if ($e->getMessage() === self::$errorMessageNamespaceNotFound) {
             return (object) ['ok' => 0, 'errmsg' => self::$errorMessageNamespaceNotFound];
         }
         throw $e;
     }
     return current($cursor->toArray());
 }
开发者ID:zivperry,项目名称:mongo-php-library,代码行数:23,代码来源:DropCollection.php

示例14: 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

示例15: execute

 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return integer
  */
 public function execute(Server $server)
 {
     $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
     $cursor = $server->executeCommand($this->databaseName, $this->createCommand(), $readPreference);
     $result = current($cursor->toArray());
     // Older server versions may return a float
     if (!isset($result->n) || !(is_integer($result->n) || is_float($result->n))) {
         throw new UnexpectedValueException('count command did not return a numeric "n" value');
     }
     return (int) $result->n;
 }
开发者ID:zivperry,项目名称:mongo-php-library,代码行数:18,代码来源:Count.php


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