當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。