__construct() public method

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.
コード例 #1
0
ファイル: MongoPlus.php プロジェクト: rudiedirkx/MongoPlus
 public function __construct(MongoPlus $mongo, $name)
 {
     $this->_mongo = $mongo;
     //		$this->_mongo_id = md5(microtime(1));
     //		$this->ref_mongo($mongo);
     parent::__construct($mongo, $name);
 }
コード例 #2
0
ファイル: mongo.php プロジェクト: binarygeotech/burgers
 /**
  *	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);
 }
コード例 #3
0
ファイル: MongoDatabase.php プロジェクト: spiral/components
 /**
  * @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']);
 }
コード例 #4
0
 /**
  * @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']);
 }
コード例 #5
0
ファイル: DB.php プロジェクト: jasny/db-mongo
 /**
  * @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;
 }
コード例 #6
0
ファイル: mongo.php プロジェクト: Mumcio/bookmark-manager
 /**
  *	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);
 }
コード例 #7
0
ファイル: Db.php プロジェクト: lisong/incubator
 public function __construct($conn, $name)
 {
     $this->conn = $conn;
     $this->name = $name;
     parent::__construct($conn, $name);
 }
コード例 #8
0
ファイル: LoggableMongoDB.php プロジェクト: mongator/mongator
 /**
  * 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);
 }
コード例 #9
0
ファイル: MongoDB.php プロジェクト: nicklasos/MongoCache
 /**
  * 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;
 }
コード例 #10
0
ファイル: Db.php プロジェクト: mongular/mongular
 /**
  * @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);
 }