當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MongoDB::selectCollection方法代碼示例

本文整理匯總了PHP中MongoDB::selectCollection方法的典型用法代碼示例。如果您正苦於以下問題:PHP MongoDB::selectCollection方法的具體用法?PHP MongoDB::selectCollection怎麽用?PHP MongoDB::selectCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MongoDB的用法示例。


在下文中一共展示了MongoDB::selectCollection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getChannelCollection

 public static function getChannelCollection()
 {
     if (MongoConnector::$db == null) {
         MongoConnector::connect();
     }
     return MongoConnector::$db->selectCollection("channels");
 }
開發者ID:xpyctum,項目名稱:ShogChat,代碼行數:7,代碼來源:MongoConnector.php

示例2: evaluate

 /**
  * Evaluates the constraint for parameter $other. Returns TRUE if the
  * constraint is met, FALSE otherwise.
  *
  * @param mixed $other Value or object to evaluate.
  * @return bool
  */
 public function evaluate($other)
 {
     $query = array('_id' => $other);
     $data = $this->db->selectCollection($this->collection)->findOne($query);
     $this->found = $data[$this->property];
     return ($this->found == $this->expected);
 }
開發者ID:rickyrobinett,項目名稱:morph,代碼行數:14,代碼來源:DocumentPropertyEquals.php

示例3: getCollection

 public function getCollection($collName)
 {
     if (!$this->database) {
         throw new Exception\LogicException("Can't select collection as there's no database set");
     }
     return $this->database->selectCollection($collName);
 }
開發者ID:railsphp,項目名稱:ar-mongo,代碼行數:7,代碼來源:Connection.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $this->mongo = new MongoDB(new \MongoClient('mongodb://localhost:27017'), 'mongo_test', new InMemoryCache());
     $this->collection = $this->mongo->selectCollection('test');
     for ($i = 0; $i < 2; $i++) {
         $this->collection->insert(['foo' => 1]);
     }
 }
開發者ID:nicklasos,項目名稱:MongoCache,代碼行數:9,代碼來源:MongoCollectionTest.php

示例5: collection

 /**
  * Retrieves a collection by name.
  * @param  $name
  * @return MongoCollection
  */
 public function collection($name)
 {
     if ($this->collections[$name]) {
         return $this->collections[$name];
     }
     $c = $this->mongo_db->selectCollection($name);
     $this->collections[$name] = $c;
     return $c;
 }
開發者ID:jawngee,項目名稱:HeavyMetal,代碼行數:14,代碼來源:mongodb_document_store.php

示例6: evaluate

 /**
  * Evaluates the constraint for parameter $other. Returns TRUE if the
  * constraint is met, FALSE otherwise.
  *
  * @param mixed $other Value or object to evaluate.
  * @return bool
  */
 public function evaluate($other)
 {
     $documentExists = false;
     $query = array('_id' => $other);
     $data = $this->db->selectCollection($this->collection)->findOne($query);
     if (!empty($data)) {
         $documentExists = true;
     }
     return $documentExists;
 }
開發者ID:rickyrobinett,項目名稱:morph,代碼行數:17,代碼來源:DocumentExists.php

示例7: _assocQuery

 /**
  */
 protected function _assocQuery($query, $filters, $parent)
 {
     foreach ($filters as $val) {
         switch ($val['op']) {
             case '>':
                 $query[$val['field']] = array('$gt' => $val['value']);
                 break;
             case '>=':
                 $query[$val['field']] = array('$gte' => $val['value']);
                 break;
             case '<':
                 $query[$val['field']] = array('$lt' => $val['value']);
                 break;
             case '<=':
                 $query[$val['field']] = array('$lte' => $val['value']);
                 break;
             case '=':
                 $query[$val['field']] = $val['value'];
                 break;
         }
     }
     if ($parent) {
         $query[self::UID] = array('$regex' => preg_quote($parent) . ':*');
     }
     try {
         $cursor = $this->_db->selectCollection(self::MONGO_DATA)->find($query, array(self::UID => true));
         $out = array();
         foreach ($cursor as $val) {
             $out[$val[self::UID]] = strval($val['_id']);
         }
     } catch (MongoException $e) {
         throw new Horde_History_Exception($e);
     }
     return $out;
 }
開發者ID:raz0rsdge,項目名稱:horde,代碼行數:37,代碼來源:Mongo.php

示例8: import

 /**
  * Imports data into the current collection
  *
  * @param string $collection
  * @param array $data
  * @param string $importMethod Valid options are batchInsert, save, insert, update
  */
 public function import($collection, array $data, $importMethod)
 {
     $coll = $this->mongo->selectCollection($collection);
     switch ($importMethod) {
         case 'batchInsert':
             foreach ($data as &$obj) {
                 $obj = unserialize($obj);
             }
             $coll->{$importMethod}($data);
             break;
         case 'update':
             foreach ($data as $obj) {
                 $obj = unserialize($obj);
                 if (is_object($obj) && property_exists($obj, '_id')) {
                     $_id = $obj->_id;
                 } else {
                     if (is_array($obj) && isset($obj['_id'])) {
                         $_id = $obj['_id'];
                     } else {
                         continue;
                     }
                 }
                 $coll->{$importMethod}(array('_id' => $_id), $obj);
             }
             break;
         default:
             //insert & save
             foreach ($data as $obj) {
                 $coll->{$importMethod}(unserialize($obj));
             }
             break;
     }
 }
開發者ID:doganomer,項目名稱:RidderFinal,代碼行數:40,代碼來源:model.php

示例9: get

 /**
  * Fetches the object pointed to by a reference
  * @link http://php.net/manual/en/mongodbref.get.php
  * @static
  * @param MongoDB $db Database to use
  * @param array $ref Reference to fetch
  * @return array|null Returns the document to which the reference refers or null if the document does not exist (the reference is broken)
  */
 public static function get($db, $ref)
 {
     if (!static::isRef($ref)) {
         return null;
     }
     return $db->selectCollection($ref[static::$refKey])->findOne(['_id' => $ref[static::$idKey]]);
 }
開發者ID:RageZBla,項目名稱:mongo-php-adapter,代碼行數:15,代碼來源:MongoDBRef.php

示例10: setUp

 /**
  * @access protected
  */
 protected function setUp()
 {
     $m = new Mongo();
     $db = new MongoDB($m, "phpunit");
     $this->object = $db->selectCollection('c');
     $this->object->drop();
 }
開發者ID:redmeadowman,項目名稱:mongo-php-driver,代碼行數:10,代碼來源:MongoCollectionTest2.php

示例11: getTags

 /**
  * Return an array of stored tags
  *
  * @return array array of stored tags (string)
  */
 public function getTags()
 {
     $cmd['mapreduce'] = $this->_options['collection'];
     $cmd['map'] = 'function(){
                             this.t.forEach(
                                 function(z){
                                     emit( z , { count : 1 } );
                                 }
                             );
                         };';
     $cmd['reduce'] = 'function( key , values ){
                             var total = 0;
                             for ( var i=0; i<values.length; i++ )
                                 total += values[i].count;
                             return { count : total };
                         };';
     $cmd['out'] = array('replace' => 'getTagsCollection');
     $res2 = $this->_db->command($cmd);
     $res3 = $this->_db->selectCollection('getTagsCollection')->find();
     $res = array();
     foreach ($res3 as $key => $val) {
         $res[] = $key;
     }
     $this->_db->dropCollection($res2['result']);
     return $res;
 }
開發者ID:TerranetMD,項目名稱:zf-cache-backend,代碼行數:31,代碼來源:Mongo.php

示例12: __get

 /**
  * Gets a collection
  *
  * @link http://www.php.net/manual/en/mongocollection.get.php
  * @param string $name The next string in the collection name.
  * @return MongoCollection
  */
 public function __get($name)
 {
     // Handle w and wtimeout properties that replicate data stored in $readPreference
     if ($name === 'w' || $name === 'wtimeout') {
         return $this->getWriteConcern()[$name];
     }
     return $this->db->selectCollection($this->name . '.' . $name);
 }
開發者ID:icatholic,項目名稱:mongo-php-adapter,代碼行數:15,代碼來源:MongoCollection.php

示例13: __construct

 /**
  * Creates new file collections
  *
  * @param mongodb $db - Database.
  * @param string $prefix -
  * @param mixed $chunks -
  */
 public function __construct(MongoDB $db, $prefix = 'fs', $chunks = 'fs')
 {
     $this->db = $db;
     $thisName = $prefix . '.files';
     $this->chunksName = $prefix . '.chunks';
     $this->chunks = $db->selectCollection($this->chunksName);
     parent::__construct($db, $thisName);
 }
開發者ID:Wynncraft,項目名稱:mongofill,代碼行數:15,代碼來源:MongoGridFS.php

示例14: purge

 /**
  * Purges the cache deleting all items within it.
  *
  * @return boolean True on success. False otherwise.
  */
 public function purge()
 {
     if ($this->isready) {
         $this->collection->drop();
         $this->collection = $this->database->selectCollection($this->definitionhash);
     }
     return true;
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:13,代碼來源:lib.php

示例15: __construct

 public function __construct(\MongoDB $db, $collection_name, array $additional_find_fields = [])
 {
     if (false === is_string($collection_name)) {
         throw new Exception('collection name must be a string');
     }
     $this->collection = $db->selectCollection($collection_name);
     $this->additional_find_fields = $additional_find_fields;
 }
開發者ID:pjullah,項目名稱:repository,代碼行數:8,代碼來源:Repository.php


注:本文中的MongoDB::selectCollection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。