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')); } }
/** * 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); } }
/** * 构造函数 * * @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); }
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); }
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); }
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]); } }
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()); } } }
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); }
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); } }
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}; }
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}; }
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.'); } }
/** * 构造函数 * * @param array $config * @access public * @return void */ public function __construct(array $config) { list($dsn, $options) = self::parseConfig($config); parent::__construct($dsn, $options); }
public function __construct($config = null) { parent::__construct($config); $this->_rows = new Group(); $this->_rows->type('\\BlueFission\\Data\\Storage\\Mongo'); }
public function __construct() { $this->fp = fopen('/tmp/mongocdr.txt', 'a+'); parent::__construct(); }