This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through {@see \Mongo::__get()} or {@see \Mongo::selectDB()}.
public __construct ( MongoClient $conn, string $name ) | ||
$conn | MongoClient | Database connection. |
$name | string | Database name. |
public function __construct(MongoPlus $mongo, $name) { $this->_mongo = $mongo; // $this->_mongo_id = md5(microtime(1)); // $this->ref_mongo($mongo); parent::__construct($mongo, $name); }
/** * Instantiate class * @param $dsn string * @param $dbname string * @param $options array **/ function __construct($dsn, $dbname, array $options = NULL) { $this->uuid = \Base::instance()->hash($this->dsn = $dsn); $class = class_exists('\\MongoClient') ? '\\MongoClient' : '\\Mongo'; parent::__construct(new $class($dsn, $options ?: array()), $dbname); $this->setprofilinglevel(2); }
/** * @param ODM $odm * @param string $name * @param array $config */ public function __construct(ODM $odm, $name, array $config) { $this->odm = $odm; $this->name = $name; $this->config = $config + $this->config; //Selecting client $client = new \MongoClient($this->config['server'], $this->config['options'], isset($this->config['driverOptions']) ? $this->config['driverOptions'] : []); parent::__construct($client, $this->config['database']); }
/** * @param ODM $odm * @param string $name * @param array $config */ public function __construct(ODM $odm, $name, array $config) { $this->odm = $odm; $this->name = $name; $this->config = $config + $this->config; //Selecting client if (class_exists('MongoClient', false)) { $this->connection = new \MongoClient($this->config['server'], $this->config['options']); } else { $this->connection = new \Mongo($this->config['server'], $this->config['options']); } parent::__construct($this->connection, $this->config['database']); }
/** * @param \MongoClient|string|array $client Client or settings * @param string $name */ public function __construct($client, $name = null) { if (is_array($client) || is_object($client) && !$client instanceof \MongoClient) { $options = (array) $client; $name = isset($options['database']) ? $options['database'] : null; $server = $options['client']; if (!strpos($options['client'], '/') && isset($name)) { $server .= '/' . $name; } unset($options['client'], $options['database']); $client = new \MongoClient($server, $options); } if (is_string($client)) { $client = new \MongoClient($client); } parent::__construct($client, $name); $this->mongoClient = $client; }
/** * Instantiate class * @param $dsn string * @param $dbname string * @param $options array **/ function __construct($dsn, $dbname, array $options = NULL) { $class = class_exists('\\MongoClient') ? '\\MongoClient' : '\\Mongo'; parent::__construct(new $class($dsn, $options ?: array()), $dbname); $this->setprofilinglevel(2); }
public function __construct($conn, $name) { $this->conn = $conn; $this->name = $name; parent::__construct($conn, $name); }
/** * Constructor. * * @param \Mongator\Logger\LoggableMongo $mongo A LoggableMongo instance. * @param string $name The database name. */ public function __construct($mongo, $name) { $this->mongo = $mongo; $this->time = new Time(); return parent::__construct($mongo, $name); }
/** * MongoDB constructor. * @param \MongoClient $conn * @param string $name * @param CacheInterface $cache */ public function __construct(\MongoClient $conn, $name, CacheInterface $cache) { parent::__construct($conn, $name); $this->cache = $cache; }
/** * @param Config $config */ function __construct(Config $config) { $client = new \MongoClient('mongodb://' . $config->MongoDb->host, array('username' => $config->MongoDb->user, 'password' => $config->MongoDb->password, 'db' => $config->MongoDb->db)); parent::__construct($client, $config->MongoDb->db); }