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