当前位置: 首页>>代码示例>>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;未经允许,请勿转载。