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


PHP MongoCollection::__construct方法代码示例

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


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

示例1: __construct

 /**
  * @param \MongoDB $db
  * @param string   $name
  * @param string   $documentClass
  */
 public function __construct(\MongoDB $db, $name, $documentClass = null)
 {
     if (isset($documentClass) && !is_a($documentClass, Entity::class, true)) {
         throw new \LogicException("Class {$documentClass} is not a " . Entity::class);
     }
     $this->documentClass = $documentClass;
     parent::__construct($db, $name);
 }
开发者ID:jasny,项目名称:db-mongo,代码行数:13,代码来源:Collection.php

示例2: __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

示例3: __construct

 /**
  * Files as stored across two collections, the first containing file meta
  * information, the second containing chunks of the actual file. By default,
  * fs.files and fs.chunks are the collection names used.
  *
  * @link http://php.net/manual/en/mongogridfs.construct.php
  * @param MongoDB $db Database
  * @param string $prefix [optional] <p>Optional collection name prefix.</p>
  * @param mixed $chunks  [optional]
  * @throws \Exception
  */
 public function __construct(MongoDB $db, $prefix = "fs", $chunks = null)
 {
     if ($chunks) {
         trigger_error("The 'chunks' argument is deprecated and ignored", E_DEPRECATED);
     }
     if (empty($prefix)) {
         throw new \Exception('MongoGridFS::__construct(): invalid prefix');
     }
     $this->database = $db;
     $this->prefix = (string) $prefix;
     $this->filesName = $prefix . '.files';
     $this->chunksName = $prefix . '.chunks';
     $this->chunks = $db->selectCollection($this->chunksName);
     parent::__construct($db, $this->filesName);
 }
开发者ID:alcaeus,项目名称:mongo-php-adapter,代码行数:26,代码来源:MongoGridFS.php

示例4: __construct

 /**
  * @param \MongoDB $db
  * @param string $name
  * @param CacheInterface $cache
  * @throws Exception
  * @return MongoCollection
  */
 public function __construct(\MongoDB $db, $name, CacheInterface $cache)
 {
     parent::__construct($db, $name);
     $this->cache = $cache;
 }
开发者ID:nicklasos,项目名称:MongoCache,代码行数:12,代码来源:MongoCollection.php

示例5: __construct

 /**
  * Constructor.
  *
  * @param \Mandango\Logger\LoggableMongoDB $db             A LoggableMongoDB instance.
  * @param string                           $collectionName The collection name.
  */
 public function __construct(LoggableMongoDB $db, $collectionName)
 {
     $this->db = $db;
     $this->time = new Time();
     parent::__construct($db, $collectionName);
 }
开发者ID:hybr,项目名称:jpm,代码行数:12,代码来源:LoggableMongoCollection.php

示例6: __construct

 public function __construct($db, $name)
 {
     $this->db = $db;
     parent::__construct($db, $name);
 }
开发者ID:lisong,项目名称:incubator,代码行数:5,代码来源:Collection.php

示例7:

 function __construct(&$provider, $tableName)
 {
     $this->provider = $provider;
     parent::__construct($this->provider->database, $tableName);
 }
开发者ID:jagermesh,项目名称:bright,代码行数:5,代码来源:BrMongoDBProvider.php

示例8: __construct

 /**
  * 构造函数
  *
  * @param Config $config            
  * @param string $collection            
  * @param string $database            
  * @param string $cluster            
  * @param string $collectionOptions            
  * @throws \Exception
  */
 public function __construct(Config $config, $collection = null, $database = DEFAULT_DATABASE, $cluster = DEFAULT_CLUSTER, $collectionOptions = null)
 {
     // 检测是否加载了FirePHP
     if (!class_exists("FirePHP")) {
         throw new \Exception('请安装FirePHP');
     }
     if (!class_exists("MongoClient")) {
         throw new \Exception('请安装MongoClient');
     }
     if ($collection === null) {
         throw new \Exception('$collection集合为空');
     }
     $this->_collection = $collection;
     $this->_database = $database;
     $this->_cluster = $cluster;
     $this->_collectionOptions = $collectionOptions;
     $this->_configInstance = $config;
     $this->_config = $config->toArray();
     if (!isset($this->_config[$this->_cluster])) {
         throw new \Exception('Config error:no cluster key');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][$this->_database])) {
         throw new \Exception('Config error:no database init');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][DB_ADMIN])) {
         throw new \Exception('Config error:admin database init');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][DB_BACKUP])) {
         throw new \Exception('Config error:backup database init');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][DB_MAPREDUCE])) {
         throw new \Exception('Config error:mapreduce database init');
     }
     $this->_db = $this->_config[$this->_cluster]['dbs'][$this->_database];
     if (!$this->_db instanceof \MongoDB) {
         throw new \Exception('$this->_db is not instanceof \\MongoDB');
     }
     $this->_admin = $this->_config[$this->_cluster]['dbs'][DB_ADMIN];
     if (!$this->_admin instanceof \MongoDB) {
         throw new \Exception('$this->_admin is not instanceof \\MongoDB');
     }
     $this->_backup = $this->_config[$this->_cluster]['dbs'][DB_BACKUP];
     if (!$this->_backup instanceof \MongoDB) {
         throw new \Exception('$this->_backup is not instanceof \\MongoDB');
     }
     $this->_mapreduce = $this->_config[$this->_cluster]['dbs'][DB_MAPREDUCE];
     if (!$this->_mapreduce instanceof \MongoDB) {
         throw new \Exception('$this->_mapreduce is not instanceof \\MongoDB');
     }
     $this->_fs = new \MongoGridFS($this->_db, GRIDFS_PREFIX);
     // 默认执行几个操作
     // 第一个操作,判断集合是否创建,如果没有创建,则进行分片处理(目前采用_ID作为片键)
     if (APPLICATION_ENV === 'production') {
         $this->shardingCollection();
     }
     parent::__construct($this->_db, $this->_collection);
     /**
      * 设定读取优先级
      * MongoClient::RP_PRIMARY 只读取主db
      * MongoClient::RP_PRIMARY_PREFERRED 读取主db优先
      * MongoClient::RP_SECONDARY 只读从db优先
      * MongoClient::RP_SECONDARY_PREFERRED 读取从db优先
      */
     // $this->db->setReadPreference(\MongoClient::RP_SECONDARY_PREFERRED);
     $this->db->setReadPreference(\MongoClient::RP_PRIMARY_PREFERRED);
 }
开发者ID:im286er,项目名称:ent,代码行数:76,代码来源:MongoCollection.php

示例9: __construct

 public function __construct(MongoDB $mongoDB, $collection_name)
 {
     $this->mongodb = $mongoDB;
     parent::__construct($this->mongodb, $collection_name);
 }
开发者ID:rjdjohnston,项目名称:MongoDB-MapReduce-PHP,代码行数:5,代码来源:XMongoCollection.php


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