array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'mongodb-driver-writeconcern.bsonserialize.php', 1 => 'MongoDB\\Driver\\WriteConcern::bsonSerialize', ), 'up' => array ( 0 => 'class.mongodb-driver-writeconcern.php', 1 => 'MongoDB\\Driver\\WriteConcern', ), 'prev' => array ( 0 => 'class.mongodb-driver-writeconcern.php', 1 => 'MongoDB\\Driver\\WriteConcern', ), 'next' => array ( 0 => 'mongodb-driver-writeconcern.construct.php', 1 => 'MongoDB\\Driver\\WriteConcern::__construct', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mongodb/mongodb/driver/writeconcern/bsonserialize.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(mongodb >=1.2.0)
MongoDB\Driver\WriteConcern::bsonSerialize — Returns an object for BSON serialization
Diese Funktion besitzt keine Parameter.
Returns an object for serializing the WriteConcern as BSON.
Beispiel #1 MongoDB\Driver\WriteConcern::bsonSerialize() with majority write concern
<?php
$wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY);
var_dump($wc->bsonSerialize());
echo "\n", MongoDB\BSON\toJSON(MongoDB\BSON\fromPHP($wc));
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
object(stdClass)#2 (1) { ["w"]=> string(8) "majority" } { "w" : "majority" }
Beispiel #2 MongoDB\Driver\WriteConcern::bsonSerialize() with wtimeout and journal
<?php
$wc = new MongoDB\Driver\WriteConcern(2, 1000, true);
var_dump($wc->bsonSerialize());
echo "\n", MongoDB\BSON\toJSON(MongoDB\BSON\fromPHP($wc));
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
object(stdClass)#2 (3) { ["w"]=> int(2) ["j"]=> bool(true) ["wtimeout"]=> int(1000) } { "w" : 2, "j" : true, "wtimeout" : 1000 }