MongoDB::setWriteConcern

(PECL mongo >=1.5.0)
Set the write concern for this database
public bool MongoDB::setWriteConcern ( mixed $w [, int $wtimeout ] )
Parameters:
w

The write concern. This may be an integer denoting the number of servers required to acknowledge the write, or a string mode (e.g. "majority").

wtimeout

The maximum number of milliseconds to wait for the server to satisfy the write concern.

Returns:

Returns TRUE on success, or FALSE otherwise.

Exception:

Emits E_WARNING if the w parameter is not an integer or string value.

Examples:
MongoDB::setWriteConcern() example
<?php

$mc = new MongoClient('mongodb://rs1.example.com,rs2.example.com');
$db = $mc->selectDB('test');

// Require that the majority of servers in the replica set acknowledge writes
// within three seconds.
$db->setWriteConcern('majority', 3000);
?>

See also:

write concern -

MongoDB::getWriteConcern() -

doc_php
2016-02-24 16:20:33
Comments
Leave a Comment

Please login to continue.