Skip to content

Commit 68916f4

Browse files
committed
edits
1 parent 3fa67b8 commit 68916f4

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

source/includes/write/replace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'borough' => 'Manhattan'
3535
];
3636

37-
$result_two = $collection->replaceOne(
37+
$result = $collection->replaceOne(
3838
['name' => 'Food Town'],
3939
$replace_document,
4040
['upsert' => true]

source/write/replace.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Replace Documents
2020
Overview
2121
--------
2222

23-
In this guide, you can learn how to use the {+library-short+} to perform a replace
24-
operation on a document in a MongoDB collection. A replace operation performs
25-
differently than an update operation. An update operation modifies only the
26-
specified fields in a target document. A replace operation removes *all* fields
23+
In this guide, you can learn how to use the {+php-library+} to run a replace
24+
operation on MongoDB collection. A replace operation performs differently
25+
than an update operation. An update operation modifies only the specified
26+
fields in a target document. A replace operation removes *all* fields
2727
in the target document and replaces them with new ones.
2828

2929
To replace a document, use the ``MongoDB\Collection::replaceOne()`` method.
@@ -98,18 +98,17 @@ methods:
9898
* - ``isAcknowledged()``
9999
- | Returns a boolean indicating whether the write operation was acknowledged.
100100

101-
102-
103101
Example
104102
~~~~~~~
105103

106104
The following example uses the ``replaceOne()`` method to replace the fields and values
107-
of a document in which the ``name`` field value is ``'Pizza Town'``:
105+
of a document in which the ``name`` field value is ``'Pizza Town'``. It then prints
106+
the number of modified documents:
108107

109108
.. io-code-block::
110109
:copyable:
111110

112-
.. input:: /includes/write/update.php
111+
.. input:: /includes/write/replace.php
113112
:start-after: start-replace-one
114113
:end-before: end-replace-one
115114
:language: php
@@ -179,11 +178,14 @@ table describes some options you can set in the array:
179178
fields </reference/command/insert/#command-fields>` guide in the
180179
{+mdb-server+} manual.
181180

181+
Example
182+
~~~~~~~
183+
182184
The following code uses the ``replaceOne()`` method to find the first document
183185
in which the ``name`` field has the value ``'Food Town'``, then replaces this document
184186
with a new document in which the ``name`` value is ``'Food World'``. Because the
185187
``upsert`` option is set to ``true``, the library inserts a new document if the query
186-
filter doesn't match any existing documents.
188+
filter doesn't match any existing documents:
187189

188190
.. literalinclude:: /includes/write/replace.php
189191
:start-after: start-replace-options
@@ -204,5 +206,5 @@ API Documentation
204206
To learn more about any of the methods or types discussed in this
205207
guide, see the following API documentation:
206208

207-
- `MongoDB\\Collection::replaceOne() <{+api+}/reference/method/MongoDBCollection-replaceOne/>`__
208-
- `MongoDB\\UpdateResult <{+api+}/reference/class/MongoDBUpdateResult/>`__
209+
- `MongoDB\\Collection::replaceOne() <{+api+}/method/MongoDBCollection-replaceOne/>`__
210+
- `MongoDB\\UpdateResult <{+api+}/class/MongoDBUpdateResult/>`__

0 commit comments

Comments
 (0)