本文整理汇总了PHP中MongoDB::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDB::__construct方法的具体用法?PHP MongoDB::__construct怎么用?PHP MongoDB::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB
的用法示例。
在下文中一共展示了MongoDB::__construct方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(MongoPlus $mongo, $name)
{
$this->_mongo = $mongo;
// $this->_mongo_id = md5(microtime(1));
// $this->ref_mongo($mongo);
parent::__construct($mongo, $name);
}
示例2: array
/**
* 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: __construct
/**
* @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: __construct
/**
* @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: __construct
/**
* @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: array
/**
* 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: __construct
public function __construct($conn, $name)
{
$this->conn = $conn;
$this->name = $name;
parent::__construct($conn, $name);
}
示例8: __construct
/**
* 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: __construct
/**
* 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: array
/**
* @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);
}