Skip to content

Commit f1397a2

Browse files
committed
DOCSP-1350: add back the PHP examples since 1.4 released
1 parent 713472c commit f1397a2

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

source/includes/3.6-drivers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- Node 3.0
55
- C# 2.5
66
- Ruby 2.5
7+
- PHP 1.4

source/tutorial/change-streams-example.txt

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ Change Stream Examples
6868
<https://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html#connect>`__
6969
that contains an ``inventory`` collection.
7070

71+
72+
- id: php
73+
content: |
74+
The examples below assume that you have `connected to a MongoDB replica set and have accessed a database
75+
<https://docs.mongodb.com/php-library/current/reference/method/MongoDBClient__construct/>`__
76+
that contains an ``inventory`` collection.
77+
7178
- id: ruby
7279
content: |
7380
The examples below assume that you have `connected to a MongoDB replica set and have accessed a database
@@ -144,6 +151,16 @@ as long as a connection to the MongoDB deployment remains open *and* the collect
144151
:start-after: Start Changestream Example 1
145152
:end-before: End Changestream Example 1
146153

154+
- id: php
155+
content: |
156+
.. class:: copyable-code
157+
158+
.. literalinclude:: /driver-examples/DocumentationExamplesTest.php
159+
:language: php
160+
:dedent: 8
161+
:start-after: Start Changestream Example 1
162+
:end-before: End Changestream Example 1
163+
147164
- id: ruby
148165
content: |
149166
.. class:: copyable-code
@@ -212,6 +229,15 @@ Lookup Full Document for Update Operations
212229
document, pass ``{ fullDocument: 'updateLookup' }`` to the
213230
:method:`collection.watch()` method.
214231

232+
- id: php
233+
content: |
234+
235+
By default, change streams only return the delta of fields
236+
during the u pdate operation. To return the most current
237+
majority-committed version of the updated document, pass
238+
``"fullDocument' => \MongoDB\Operation\ChangeStreamCommand::FULL_DOCUMENT_UPDATE_LOOKUP"``
239+
to the :method:`watch()` method.
240+
215241
- id: ruby
216242
content: |
217243
By default, change streams only return the delta of fields during the update operation.
@@ -297,12 +323,22 @@ update operation.
297323
:start-after: Start Changestream Example 2
298324
:end-before: End Changestream Eample 2
299325

326+
- id: php
327+
content: |
328+
.. class:: copyable-code
329+
330+
.. literalinclude:: /driver-examples/DocumentationExamplesTest.php
331+
:language: php
332+
:dedent: 8
333+
:start-after: Start Changestream Example 2
334+
:end-before: End Changestream Example 2
335+
300336
- id: ruby
301337
content: |
302338
.. class:: copyable-code
303339

304340
.. literalinclude:: /driver-examples/change_stream_examples_spec.rb
305-
:language: php
341+
:language: ruby
306342
:dedent: 4
307343
:start-after: Start Changestream Example 2
308344
:end-before: End Changestream Example 2
@@ -501,6 +537,29 @@ Resume a Change Stream
501537
:start-after: Start Changestream Example 3
502538
:end-before: End Changestream Example 3
503539

540+
- id: php
541+
content: |
542+
543+
Each change stream response document has an ``_id`` field
544+
which can be passed to the ``watch()`` method, indicating to
545+
the method at what point in th e iteration of the change
546+
stream it should resume.
547+
548+
In the example below, the ``resumeAfter`` option is passed to
549+
the ``watch()`` method with a value of the ``_id`` of the last
550+
document processed, in order to recreate the stream after it
551+
has been destroyed. Passing the ``_id`` to the change stream
552+
attempts to resume notifications starting at the operation
553+
specified.
554+
555+
.. class:: copyable-code
556+
557+
.. literalinclude:: /driver-examples/DocumentationExamplesTest.php
558+
:language: php
559+
:dedent: 8
560+
:start-after: Start Changestream Example 3
561+
:end-before: End Changestream Example 3
562+
504563
- id: ruby
505564
content: |
506565
Each change stream response document has an ``_id`` field which can be passed

0 commit comments

Comments
 (0)