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


PHP Mongo::__construct方法代码示例

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


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

示例1: catch

 function __construct()
 {
     //allow mongo to use 64bit ints
     ini_set('mongo.native_long', 1);
     // Fetch CodeIgniter instance
     $ci = get_instance();
     // Load Mongo configuration file
     $ci->load->config('mongo');
     // Fetch Mongo server and database configuration
     $server = $ci->config->item('mongo_server');
     $username = $ci->config->item('mongo_username');
     $password = $ci->config->item('mongo_password');
     $dbname = $ci->config->item('mongo_dbname');
     try {
         if ($ci->config->item('mongo_auth') === FALSE) {
             parent::__construct("mongodb://" . $server . "/" . $dbname);
         } else {
             parent::__construct("mongodb://{$username}:{$password}@{$server}/{$dbname}");
         }
         $this->db = $this->{$dbname};
     } catch (MongoConnectionException $e) {
         //Don't show Mongo Exceptions as they can contain authentication info
         $_error =& load_class('Exceptions', 'core');
         exit($_error->show_error('MongoDB Connection Error', 'A MongoDB error occured while trying to connect to the database!', 'error_db'));
     } catch (Exception $e) {
         $_error =& load_class('Exceptions', 'core');
         exit($_error->show_error('MongoDB Error', $e->getMessage(), 'error_db'));
     }
 }
开发者ID:nodecast,项目名称:projectNarwhal,代码行数:29,代码来源:Mongo.php

示例2: __construct

 /**
  * Creates a new Mongo database connection
  * @param string $server Mongo connection string, eg. mongodb://localhost:27017
  * @param array $options Refer to http://www.php.net/manual/en/mongo.construct.php
  * @param int $debugProfileLevel Default is 0 (Off)
  */
 public function __construct($server, $options = null, $debugProfileLevel = 0)
 {
     parent::__construct($server, $options);
     if ($debugProfileLevel > 0) {
         $this->enableDebug($debugProfileLevel);
     }
 }
开发者ID:ENGINETEC,项目名称:esquire,代码行数:13,代码来源:DooMongo.php

示例3: __construct

 /**
  * 构造函数
  *
  * @param array $config
  * @access public
  * @return void
  */
 public function __construct(array $config)
 {
     list($dsn, $options) = self::parseConfig($config);
     if (!isset($options['persist'])) {
         $options['persist'] = $dsn;
     }
     parent::__construct($dsn, $options);
 }
开发者ID:neoisldl,项目名称:Onion,代码行数:15,代码来源:mongo.php

示例4: __construct

 public function __construct($connection = 'default')
 {
     $this->config = new Library_config();
     $this->database = $this->config->mongodb->{$connection}->database;
     $host = $this->config->mongodb->{$connection}->host;
     /**
      * EN: This is the mongodb connection option. Eg: array('replicaSet' => true, 'connect' => false)
      */
     $connection_options = array();
     parent::__construct($host, $connection_options);
 }
开发者ID:erxn,项目名称:siemas,代码行数:11,代码来源:mongodb.php

示例5: __construct

 public function __construct($connectionString = null, array $options = array())
 {
     Shanty_Mongo::init();
     // Set the server to local host if one was not provided
     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:stunti,项目名称:Shanty-Mongo,代码行数:12,代码来源:Connection.php

示例6: __construct

 public function __construct($server = 'mongodb://localhost:27017', $options = array('connect' => false))
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     $this->options = array_merge(array('connect' => false, 'initialize_on_connect' => true), $options);
     parent::__construct($server, $this->options);
     self::$_connection = $this;
     if (preg_match('|/([a-zA-Z][a-zA-Z0-9_]*)$|', $server, $matches)) {
         $this->setDefaultDB($matches[1]);
     }
 }
开发者ID:Artera,项目名称:artera-mongo,代码行数:12,代码来源:Mongo.php

示例7: open

 public function open()
 {
     if (!$this->_connected) {
         try {
             //$password = Common::mysql_db_encrypt($this->password);
             //parent::__construct($this->dsn, $this->username, $password, $this->options);
             parent::__construct($this->server);
             $this->_connected = true;
         } catch (Exception $e) {
             throw new Yaf_Exception('连接MongoDB失败: ' . $e->getMessage());
         }
     }
 }
开发者ID:nbaiwan,项目名称:yav,代码行数:13,代码来源:CMongo.php

示例8: __construct

 public function __construct($connectionString = null, array $options = array())
 {
     Shanty_Mongo::init();
     // Set the server to local host if one was not provided
     if (is_null($connectionString)) {
         $connectionString = '127.0.0.1';
     }
     // Force mongo to connect only when we need to
     $options['connect'] = false;
     $connectionInfo = self::parseConnectionString($connectionString);
     $this->_connectionInfo = array_merge($options, $connectionInfo);
     return parent::__construct($connectionString, $options);
 }
开发者ID:hongliang,项目名称:Shanty-Mongo,代码行数:13,代码来源:Connection.php

示例9: __construct

 public function __construct()
 {
     $this->ci = get_instance();
     $this->ci->config->load('mongo');
     try {
         parent::__construct(config_item('mongo_host') . ':' . config_item('mongo_port'));
     } catch (MongoConnectionException $e) {
         show_error("MongoDB connection failed: {$e->getMessage()}", 500);
     }
     if (!config_item('mongo_database')) {
         show_error('mongo_database can not empty.', 500);
     }
 }
开发者ID:navruzm,项目名称:navruz.net,代码行数:13,代码来源:Mongo_db.php

示例10:

 function CI_Mongo()
 {
     $CI =& get_instance();
     $CI->load->config('mongodb');
     $server = $CI->config->item('host');
     $dbname = $CI->config->item('database');
     // Initialize MongoDB Configuration
     if ($server) {
         parent::__construct($server);
     } else {
         parent::__construct();
     }
     $this->db = $this->{$dbname};
 }
开发者ID:shinichi81,项目名称:mongodb-ci-crud,代码行数:14,代码来源:Mongo.php

示例11:

 function CI_Mongo()
 {
     // Fetch CodeIgniter instance
     $ci = get_instance();
     // Load Mongo configuration file
     $ci->load->config('mongo');
     // Fetch Mongo server and database configuration
     $server = $ci->config->item('mongo_server');
     $dbname = $ci->config->item('mongo_dbname');
     // Initialise Mongo
     if ($server) {
         parent::__construct($server);
     } else {
         parent::__construct();
     }
     $this->db = $this->{$dbname};
 }
开发者ID:HipsterJazzbo,项目名称:Syncosaurus,代码行数:17,代码来源:Mongo.php

示例12: __construct

 public function __construct($config, $connectionName)
 {
     /**
      * Makesure Mongo extension is enabled
      */
     if (!class_exists('Mongo')) {
         throw new RunException('Mongo PECL extension that required by Mongodb Driver is not available.');
     }
     $this->config = $config;
     $this->connection = $connectionName;
     /**
      * $this->config['options'] is the mongodb connection option. Eg: array('replicaSet' => true, 'connect' => false)
      */
     try {
         parent::__construct($this->config['host'], $this->config['options']);
     } catch (\MongoConnectionException $e) {
         RunException::outputError('Unable connect to database in <strong>' . $connectionName . '</strong> connection.');
     }
 }
开发者ID:ainuloverflow,项目名称:raportonline,代码行数:19,代码来源:Mongodb.php

示例13: __construct

 /**
  * 构造函数
  *
  * @param array $config
  * @access public
  * @return void
  */
 public function __construct(array $config)
 {
     list($dsn, $options) = self::parseConfig($config);
     parent::__construct($dsn, $options);
 }
开发者ID:yeaha,项目名称:lysine,代码行数:12,代码来源:mongo.php

示例14: __construct

 public function __construct($config = null)
 {
     parent::__construct($config);
     $this->_rows = new Group();
     $this->_rows->type('\\BlueFission\\Data\\Storage\\Mongo');
 }
开发者ID:bluefission,项目名称:DevElation,代码行数:6,代码来源:MongoBulk.php

示例15: __construct

 public function __construct()
 {
     $this->fp = fopen('/tmp/mongocdr.txt', 'a+');
     parent::__construct();
 }
开发者ID:swk,项目名称:bluebox,代码行数:5,代码来源:MongoCdr.php


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