本文整理汇总了PHP中MongoClient::getWriteConcern方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoClient::getWriteConcern方法的具体用法?PHP MongoClient::getWriteConcern怎么用?PHP MongoClient::getWriteConcern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoClient
的用法示例。
在下文中一共展示了MongoClient::getWriteConcern方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWriteConcern
/**
* Get an array describing the write concern for this connection
*
* @since 1.0.0
*
* @link http://php.net/manual/en/mongo.writeconcerns.php Write Concern
*
* @return array
*/
public function getWriteConcern()
{
// PECL mongo >=1.5.0
if (version_compare(\MongoClient::VERSION, '1.5.0') >= 0) {
return $this->connection->getWriteConcern();
}
return array('w' => $this->config['connection']['options']['w'], 'wtimeout' => $this->config['connection']['options']['wTimeoutMS']);
}
示例2: __construct
/**
* Creates a new database
*
* 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()}.
* @link http://www.php.net/manual/en/mongodb.construct.php
* @param MongoClient $conn Database connection.
* @param string $name Database name.
* @throws Exception
* @return MongoDB Returns the database.
*/
public function __construct(MongoClient $conn, $name)
{
$this->connection = $conn;
$this->name = $name;
$this->setReadPreferenceFromArray($conn->getReadPreference());
$this->setWriteConcernFromArray($conn->getWriteConcern());
$this->createDatabaseObject();
}