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


PHP MongoClient::__construct方法代码示例

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


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

示例1: __construct

 public function __construct($config = array(), $options = array('connect' => true))
 {
     try {
         $this->_config($config);
         // настраиваем тестовое окружение
         $connection = defined('TESTING_IS_GOING_ON') && TESTING_IS_GOING_ON && !empty($this->_config['test']) ? $this->_config['test'] : $this->_config['server'];
         $server = '';
         if (!empty($connection['user'])) {
             $server .= $connection['user'];
         }
         if (!empty($connection['password'])) {
             $server .= ":{$connection['password']}";
         }
         if (!empty($server)) {
             $server .= "@";
         }
         $server .= "{$connection['host']}:{$connection['port']}";
         $server = "mongodb://{$server}";
         // соединяемся
         parent::__construct($server, $options);
         if (!empty($connection['db'])) {
             $this->_Db = new \MongoDb($this, $connection['db']);
             if (!empty($this->_config['collection'])) {
                 $this->_Collection = new \MongoCollection($this->_Db, $this->_config['collection']);
             }
         }
     } catch (\MongoException $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:pdedkov,项目名称:db,代码行数:30,代码来源:Instance.php

示例2: __construct

 /**
  * Tries to connect to a MySQL Server
  */
 public function __construct($db_host, $db_user, $db_pass, $db_name)
 {
     $this->dbName = $db_name;
     if ($db_user != "" || $db_pass != "") {
         $mongoAuth = $uri = $db_user . ":" . $db_pass . "@";
     }
     $uri = "mongodb://" . $mongoAuth . $db_host . "/" . $db_name;
     parent::__construct($uri);
 }
开发者ID:pars5555,项目名称:crm,代码行数:12,代码来源:MongoDBMS.class.php

示例3: __construct

 public function __construct($connectionString = null, array $options = array())
 {
     if (is_null($connectionString)) {
         $connectionString = '127.0.0.1';
     }
     // $options['connect'] = false;
     $this->_connectionInfo = $options;
     $this->_connectionInfo['connectionString'] = $connectionString;
     return parent::__construct($connectionString, $options);
 }
开发者ID:aaroncox,项目名称:epicmongo,代码行数:10,代码来源:Connection.php

示例4: unserialize

 /**
  */
 public function unserialize($data)
 {
     list($this->dbname, $this->_cArgs) = unserialize($data);
     parent::__construct($this->_cArgs[0], $this->_cArgs[1]);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:7,代码来源:Client.php


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