PHP - Manual: MongoDB::getWriteConcern
2024-12-24
(PECL mongo >=1.5.0)
MongoDB::getWriteConcern — Get the write concern for this database
此函数没有参数。
This function returns an array describing the write concern. The array contains the values w for an integer acknowledgement level or string mode, and wtimeout denoting the maximum number of milliseconds to wait for the server to satisfy the write concern.
Example #1 MongoDB::getWriteConcern() return value example
<?php
$mc = new MongoClient('mongodb://localhost:27017', array('wTimeoutMS' => 500));
$db = $mc->selectDB('test');
var_dump($db->getWriteConcern());
$db->setWriteConcern(1, 1000);
var_dump($db->getWriteConcern());
?>
以上例程会输出:
array(2) { ["w"]=> int(1) ["wtimeout"]=> int(500) } array(2) { ["w"]=> int(1) ["wtimeout"]=> int(1000) }
官方地址:https://www.php.net/manual/en/mongodb.getwriteconcern.php