Skip to content

Commit 80dc68d

Browse files
committed
Merge pull request #477
2 parents 54dfa9f + e724acc commit 80dc68d

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
...

source/reference/class/MongoDBClient.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ Methods
3939
/reference/method/MongoDBClient-listDatabases
4040
/reference/method/MongoDBClient-selectCollection
4141
/reference/method/MongoDBClient-selectDatabase
42+
/reference/method/MongoDBClient-startSession
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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

0 commit comments

Comments
 (0)