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


PHP MongoClient::selectCollection方法代码示例

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


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

示例1: getCollection

 protected function getCollection()
 {
     if (!$this->coll) {
         $this->coll = $this->mongoClient->selectCollection($this->dbName, $this->collName);
     }
     return $this->coll;
 }
开发者ID:rybakit,项目名称:phive-queue,代码行数:7,代码来源:MongoQueue.php

示例2: getCollection

 /**
  * Return the mongo collection with given name
  *
  * @param $name
  * @return \MongoCollection
  */
 protected function getCollection($name)
 {
     if (!$this->db) {
         global $config;
         $this->setDb(MongoProvider::getClient($config['db']['host'], array()));
     }
     return $this->db->selectCollection('shortener', 'links');
 }
开发者ID:alebon,项目名称:url-shortener-php,代码行数:14,代码来源:WebController.php

示例3: __construct

 public function __construct(\MongoClient $mongoClient, $database, $collection)
 {
     $this->setMongoClient($mongoClient);
     $this->setDatabase($database);
     $this->setCollection($collection);
     $this->mongoCollection = $this->mongoClient->selectCollection($this->database, $this->collection);
     $this->mongoCollection->ensureIndex(array('expires' => 1), array('expireAfterSeconds' => 0));
 }
开发者ID:myurasov,项目名称:mym-auth,代码行数:8,代码来源:MongoAuthService.php

示例4: setUp

 /**
  * Setup performed prior to each test method
  *
  * @return void
  */
 public function setUp()
 {
     if (!extension_loaded('mongo')) {
         $this->markTestSkipped('Zend\\Session\\SaveHandler\\MongoDB tests are not enabled due to missing Mongo extension');
     }
     $this->options = new MongoDBOptions(array('database' => 'zf2_tests', 'collection' => 'sessions'));
     $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\\Mongo' : '\\MongoClient';
     $this->mongo = new $mongoClass();
     $this->mongoCollection = $this->mongo->selectCollection($this->options->getDatabase(), $this->options->getCollection());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:15,代码来源:MongoDBTest.php

示例5: __construct

 /**
  * @param array $injectors
  */
 public function __construct(array $injectors = array())
 {
     parent::__construct($injectors);
     if (!$this->injectors['client']) {
         $this->injectors['client'] = new \MongoClient($this->injectors['dsn'], $this->injectors['options']);
     }
     // Set client and collection
     $this->client = $this->injectors['client'];
     $this->collection = $this->client->selectCollection($this->injectors['database'], $this->injectors['collection']);
 }
开发者ID:pagon,项目名称:logger,代码行数:13,代码来源:MongoDB.php

示例6: __construct

 public function __construct($server = 'mongodb://localhost:27017', $db = 'phpconsole', $collection = 'phpconsole')
 {
     $this->mongoClient = new \MongoClient($server);
     if (!$this->mongoClient) {
         throw new \Exception('Unable to connect to MongoDB server');
     }
     $this->mongoCollection = $this->mongoClient->selectCollection($db, $collection);
     if (!$this->mongoCollection) {
         throw new \Exception('Unable to get collection');
     }
     $this->mongoCollection->ensureIndex(array('expireAt' => 1), array('background' => true, 'name' => 'TTL', 'expireAfterSeconds' => 0));
 }
开发者ID:rafabrutaldrums,项目名称:casamacario,代码行数:12,代码来源:MongoDB.php

示例7: selectCollection

 /**
  * @see MongoClient#selectCollection
  */
 public function selectCollection($db, $collection = null)
 {
     if (empty($db)) {
         $db = $this->dbname;
     }
     return parent::selectCollection($db, $collection);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:10,代码来源:Client.php

示例8: getCollection

 /**
  * Return a "MongoCollection" instance.
  *
  * @return \MongoCollection
  */
 private function getCollection()
 {
     if (null === $this->collection) {
         $this->collection = $this->mongo->selectCollection($this->options['database'], $this->options['collection']);
     }
     return $this->collection;
 }
开发者ID:Gladhon,项目名称:symfony,代码行数:12,代码来源:MongoDbSessionHandler.php

示例9: getCollection

 /**
  * Get mongo db stream collection
  *
  * @return \MongoCollection
  */
 private function getCollection()
 {
     if (null === $this->collection) {
         $this->collection = $this->mongoClient->selectCollection($this->dbName, $this->streamCollectionName);
         $this->collection->setReadPreference(\MongoClient::RP_PRIMARY);
     }
     return $this->collection;
 }
开发者ID:bweston92,项目名称:event-store-mongodb-adapter,代码行数:13,代码来源:MongoDbEventStoreAdapter.php

示例10: getMongoCollection

 /**
  * @return \MongoCollection
  */
 private function getMongoCollection()
 {
     // connect to the database
     if (!$this->mongoCollection) {
         $mongoClient = new \MongoClient($this->server);
         $this->mongoCollection = $mongoClient->selectCollection($this->database, $this->collection);
     }
     return $this->mongoCollection;
 }
开发者ID:myurasov,项目名称:mym-crawler,代码行数:12,代码来源:MongoRepository.php

示例11: lastpage

 function lastpage($userid)
 {
     $m = new MongoClient();
     $collection = $m->selectCollection('thefacebook', 'log');
     $cursor = $collection->find(array('userid' => $userid));
     $cursor->sort(array('timestamp' => -1))->limit(2);
     $records = iterator_to_array($cursor);
     return $records[1]['page'];
 }
开发者ID:jesobreira,项目名称:thefacebook.us,代码行数:9,代码来源:Log.php

示例12: __construct

 /**
  * Create a new cursor
  * @link http://www.php.net/manual/en/mongocursor.construct.php
  * @param \MongoClient $connection Database connection.
  * @param string $ns Full name of database and collection.
  */
 public function __construct(\MongoClient $connection, $ns)
 {
     $this->connection = $connection;
     $this->ns = $ns;
     $nsParts = explode('.', $ns);
     $dbName = array_shift($nsParts);
     $collectionName = implode('.', $nsParts);
     $this->db = $connection->selectDB($dbName)->getDb();
     if ($collectionName) {
         $this->collection = $connection->selectCollection($dbName, $collectionName)->getCollection();
     }
 }
开发者ID:lewnie,项目名称:mongo-php-adapter,代码行数:18,代码来源:AbstractCursor.php

示例13: GetVehicle

 public function GetVehicle($params)
 {
     if (mb_strlen($params->Vehicle->RegistrationNumber) < 2) {
         return (object) ['VehicleList' => []];
     }
     $conn = new MongoClient(sprintf('mongodb://%s:%s@%s', MDB_USER, MDB_PASSWORD, MDB_HOST));
     $mtVehicle = $conn->selectCollection(MDB_DATABASE, 'Vehicle');
     $qsGetVehicle = ['A07' => ['$regex' => '.*', '$options' => 'i']];
     $qsGetVehicle = ['A07' => 'Л8195ГО'];
     $mCursor = $mtVehicle->find($qsGetVehicle);
     $vehicles = [];
     foreach ($mCursor as $mRecord) {
         array_push($vehicles, ['RegistrationNumber' => $mRecord['A07'], 'Brand' => 'не указан', 'Model' => 'не указана', 'Color' => 'не указан', 'OwnerFirstName' => $mRecord['IMA'], 'OwnerPatronymic' => $mRecord['A28'], 'OwnerLastName' => $mRecord['A26'], 'OwnerBirthday' => $mRecord['A29'], 'ProductionYear' => $mRecord['A12'], 'OwnerRegionCode' => $mRecord[''], 'OwnerCity' => $mRecord['A35'], 'OwnerStreet' => $mRecord['A36'], 'OwnerHouse' => $mRecord['A37'], 'OwnerBuilding' => $mRecord['A38'], 'OwnerApartment' => $mRecord['A39'], 'VIN' => $mRecord['VIN']]);
     }
     return (object) ['VehicleList' => $vehicles];
 }
开发者ID:antim5,项目名称:nn-soap-server,代码行数:16,代码来源:Vehicle.php

示例14: open

 public function open($save_path, $name)
 {
     $result = false;
     try {
         $mongo = new MongoClient($this->_options['mongo']['server']);
         $this->_session = $mongo->selectCollection($this->_options['mongo']['dbname'], 'Session');
     } catch (Exception $e) {
         if (APPLICATION_ENV != 'production') {
             echo "Mongo session start fails: " . $e->getMessage();
             exit;
         } else {
             throw $e;
         }
     }
     if ($this->_session) {
         $result = true;
     }
     return $result;
 }
开发者ID:ud223,项目名称:yj,代码行数:19,代码来源:Mongo.php

示例15: __construct

 /**
  * Creates a new cursor
  */
 public function __construct()
 {
     $arguments = func_get_args();
     if (!empty($arguments) && $arguments[0] instanceof \MongoCursor) {
         $this->_cursor = $arguments[0];
         $info = $this->_cursor->info();
         list($dbName, $collectionName) = explode('.', $info['ns'], 2);
         if (!isset($arguments[1]) || !$arguments[1] instanceof Collection) {
             throw new \RuntimeException('Modomo\\MongoCursor::__construct() expects parameter 2 to be of type Modomo\\Adapters\\MongoCollection');
         }
         $this->_collection = $arguments[1];
     } else {
         $class = new \ReflectionClass('\\MongoCursor');
         $this->_cursor = $class->newInstanceArgs($arguments);
         $info = $this->_cursor->info();
         list($dbName, $collectionName) = explode('.', $info['ns'], 2);
         $conn = new MongoClient($arguments[0]);
         $this->_collection = $conn->selectCollection($dbName, $collectionName);
     }
 }
开发者ID:jrschumacher,项目名称:modomo,代码行数:23,代码来源:MongoCursor.php


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