本文整理汇总了PHP中MongoDB::getReadPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDB::getReadPreference方法的具体用法?PHP MongoDB::getReadPreference怎么用?PHP MongoDB::getReadPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB
的用法示例。
在下文中一共展示了MongoDB::getReadPreference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new collection
*
* @param MongoDB $db - Parent database.
* @param string $name -
*
* @return - Returns a new collection object.
*/
public function __construct(MongoDB $db, $name)
{
$this->db = $db;
$this->name = $name;
$this->readPreference = $db->getReadPreference();
$this->fqn = $db->_getFullCollectionName($name);
$this->client = $db->_getClient();
}
示例2: __construct
/**
* Creates a new collection
*
* @link http://www.php.net/manual/en/mongocollection.construct.php
* @param MongoDB $db Parent database.
* @param string $name Name for this collection.
* @throws Exception
* @return MongoCollection
*/
public function __construct(MongoDB $db, $name)
{
$this->db = $db;
$this->name = $name;
$this->setReadPreferenceFromArray($db->getReadPreference());
$this->setWriteConcernFromArray($db->getWriteConcern());
$this->createCollectionObject();
}
示例3: getReadPreference
/**
* Wrapper method for MongoDB::getReadPreference().
*
* For driver versions between 1.3.0 and 1.3.3, the return value will be
* converted for consistency with {@link Database::setReadPreference()}.
*
* @see http://php.net/manual/en/mongodb.getreadpreference.php
* @return array
*/
public function getReadPreference()
{
return $this->mongoDB->getReadPreference();
}
示例4: getReadPreference
/**
* Wrapper method for MongoDB::getReadPreference().
*
* For driver versions between 1.3.0 and 1.3.3, the return value will be
* converted for consistency with {@link Database::setReadPreference()}.
*
* @see http://php.net/manual/en/mongodb.getreadpreference.php
* @return array
*/
public function getReadPreference()
{
return ReadPreference::convertReadPreference($this->mongoDB->getReadPreference());
}