Skip to content

Commit 04ca6f7

Browse files
committed
Explain type map overriding codecs
1 parent d639a19 commit 04ca6f7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
// Returns a document using the default type map
4-
$collection->findOne($filter, ['codec' => null]);
5-
6-
// Disables codec usage as the aggregate result will have a different format
3+
// Overrides the collection codec, falling back to the default type map
74
$collection->aggregate($pipeline, ['codec' => null]);
5+
6+
// Overrides the collection codec, using the specified type map
7+
$collection->findOne($filter, ['typeMap' => ['root' => 'stdClass']]);

docs/tutorial/codecs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ operations will attempt to decode returned documents using the provided codec. I
5252
returned, an exception will be thrown.
5353

5454
You can disable codec usage for a specific operation or use a different codec (e.g. to decode the result of an
55-
aggregation pipeline) by specifying the ``null`` for the ``codec`` option for any operation. This will override the
56-
collection-level codec:
55+
aggregation pipeline) by specifying ``null`` for the ``codec`` option for any operation. Alternatively, specifying a
56+
type map using the ``typeMap`` operation will also override the collection-level codec:
5757

5858
.. literalinclude:: /examples/codecs/handling-documents/disabling-codec.php
5959
:language: php

0 commit comments

Comments
 (0)