File tree Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -105,11 +105,25 @@ Replica Set
105
105
106
106
The following code shows how to connect to a replica set deployment:
107
107
108
- .. literalinclude:: /includes/usage-examples/connect-code-examples.php
109
- :language: php
110
- :dedent:
111
- :start-after: start-replica-set
112
- :end-before: end-replica-set
108
+ .. tabs::
109
+
110
+ .. tab:: MongoDB\\Client
111
+ :tabid: Client
112
+
113
+ .. literalinclude:: /includes/usage-examples/connect-code-examples.php
114
+ :language: php
115
+ :dedent:
116
+ :start-after: start-replica-set-client
117
+ :end-before: end-replica-set-client
118
+
119
+ .. tab:: Connection URI
120
+ :tabid: connectionstring
121
+
122
+ .. literalinclude:: /includes/usage-examples/connect-code-examples.php
123
+ :language: php
124
+ :dedent:
125
+ :start-after: start-replica-set-uri
126
+ :end-before: end-replica-set-uri
113
127
114
128
To learn more about connecting to a replica set, see :ref:`php-connection-replica-set`
115
129
in the Connection Targets guide.
Original file line number Diff line number Diff line change 14
14
$ client = new MongoDB \Client ($ uri );
15
15
// end-atlas
16
16
17
- // Connects to a replica set
18
- // start-replica-set
17
+ // Connects to a replica set using client options
18
+ // start-replica-set-client
19
+ $ client = new MongoDB \Client (
20
+ 'mongodb://<replica set member>:<port>/ ' ,
21
+ ['replicaSet ' => '<replica set name> ' ],
22
+ );
23
+ // end-replica-set-client
24
+
25
+ // Connects to a replica set using a connection URI parameter
26
+ // start-replica-set-uri
19
27
$ uri = 'mongodb://<replica set member>:<port>/?replicaSet=<replica set name> ' ;
20
28
$ client = new MongoDB \Client ($ uri );
21
- // end-replica-set
29
+ // end-replica-set-uri
22
30
23
31
// Connects to a MongoDB deployment and enables TLS using client
24
32
// options
You can’t perform that action at this time.
0 commit comments