MongoDB\Client::startSession()
New in version 1.3.
Definition
Parameters
$options
: array- An array specifying the desired options. Refer to the MongoDB\Driver\Manager::startSession() extension documentation for a list of supported options.
Return Values
A MongoDB\Driver\Session object.
Errors/Exceptions
MongoDB\Driver\Exception\InvalidArgumentException for errors related to the parsing of parameters or options at the extension level.
MongoDB\Driver\Exception\RuntimeException for other errors at the extension level (e.g. connection errors).
Example
The following example starts a new session:
$client = new MongoDB\Client; $session = $client->startSession(); var_dump($session);
The output would then resemble:
object(MongoDB\Driver\Session)#2043 (4) { ["logicalSessionId"]=> array(1) { ["id"]=> object(MongoDB\BSON\Binary)#225 (2) { ["data"]=> string(16) "................" ["type"]=> int(4) } } ["clusterTime"]=> NULL ["causalConsistency"]=> bool(true) ["operationTime"]=> NULL }
See Also
Causal Consistency in the MongoDB manual