php8.5
Home/ Manual/ driver / writeconcern/ MongoDB\Driver\WriteConcern::getW

MongoDB\Driver\WriteConcern::getW

PHP function Edit on GitHub ✎

(mongodb >=1.0.0)

Returns the WriteConcern's "w" option

Description

MongoDB\Driver\WriteConcern::getW(): string|int|null

Parameters Parameters

Return Values

Returns the WriteConcern's "w" option.

Errors/Exceptions

Examples

MongoDB\Driver\WriteConcern::getW() example

php
<?php

$wc = new MongoDB\Driver\WriteConcern(1);
var_dump($wc->getW());

$wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY);
var_dump($wc->getW());

?>

The above example will output:

output
int(1)
string(8) "majority"

See Also

  • Write Concern reference

Source: reference/mongodb/mongodb/driver/writeconcern/getw.xml · from the official PHP manual (php/doc-en)