File tree Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ arg_name : option
2
+ name : causalConsistency
3
+ type : boolean
4
+ description : |
5
+ Enables or disables :ref:`causal consistency <causal-consistency>` for the
6
+ session. If true, each operation in the session will be causally ordered after
7
+ the previous read or write operation. Set to false to disable causal
8
+ consistency. Defaults to true.
9
+ interface : phpmethod
10
+ operation : ~
11
+ optional : true
12
+ ...
Original file line number Diff line number Diff line change @@ -39,3 +39,4 @@ Methods
39
39
/reference/method/MongoDBClient-listDatabases
40
40
/reference/method/MongoDBClient-selectCollection
41
41
/reference/method/MongoDBClient-selectDatabase
42
+ /reference/method/MongoDBClient-startSession
Original file line number Diff line number Diff line change
1
+ ===============================
2
+ MongoDB\\Client::startSession()
3
+ ===============================
4
+
5
+ .. default-domain:: mongodb
6
+
7
+ .. versionadded:: 1.3
8
+
9
+ .. contents:: On this page
10
+ :local:
11
+ :backlinks: none
12
+ :depth: 1
13
+ :class: singlecol
14
+
15
+ Definition
16
+ ----------
17
+
18
+ .. phpmethod:: MongoDB\\Client::startSession()
19
+
20
+ Start a new client session for use with this client.
21
+
22
+ .. code-block:: php
23
+
24
+ function startSession(array $options = []): MongoDB\Driver\Session
25
+
26
+ The ``$options`` parameter supports the following options:
27
+
28
+ .. include:: /includes/apiargs/MongoDBClient-method-startSession-option.rst
29
+
30
+ Return Values
31
+ -------------
32
+
33
+ A :php:`MongoDB\Driver\Session <mongodb-driver-session>`
34
+
35
+ Errors/Exceptions
36
+ -----------------
37
+
38
+ .. include:: /includes/extracts/error-driver-invalidargumentexception.rst
39
+ .. include:: /includes/extracts/error-driver-runtimeexception.rst
40
+
41
+ Example
42
+ -------
43
+
44
+ The following example starts a new session:
45
+
46
+ .. code-block:: php
47
+
48
+ <?php
49
+
50
+ $client = new MongoDB\Client;
51
+
52
+ $session = $client->startSession();
53
+
54
+ var_dump($session);
55
+
56
+ The output would then resemble::
57
+
58
+ object(MongoDB\Driver\Session)#2043 (4) {
59
+ ["logicalSessionId"]=>
60
+ array(1) {
61
+ ["id"]=>
62
+ object(MongoDB\BSON\Binary)#225 (2) {
63
+ ["data"]=>
64
+ string(16) "................"
65
+ ["type"]=>
66
+ int(4)
67
+ }
68
+ }
69
+ ["clusterTime"]=>
70
+ NULL
71
+ ["causalConsistency"]=>
72
+ bool(true)
73
+ ["operationTime"]=>
74
+ NULL
75
+ }
76
+
77
+ See Also
78
+ --------
79
+
80
+ - :php:`MongoDB\\Driver\\Manager::startSession()
81
+ <manual/en/mongodb-driver-manager.startsession.php>`
82
+ - :ref:`Causal Consistency <causal-consistency>` in the MongoDB manual
You can’t perform that action at this time.
0 commit comments