File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
includes/fundamentals/read-operations Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -634,7 +634,7 @@ The ``readPreference()`` method accepts the following parameters:
634634 in the MongoDB PHP extension documentation.
635635
636636The following example queries for documents in which the value of the ``title``
637- field is ``"Carrie"`` and sets the read preference to ``"secondaryPreferred" ``.
637+ field is ``"Carrie"`` and sets the read preference to ``ReadPreference::SECONDARY_PREFERRED ``.
638638As a result, the query retrieves the results from secondary replica set
639639members or the primary member if no secondaries are available:
640640
@@ -668,7 +668,7 @@ members or the primary member if no secondaries are available:
668668 public function show()
669669 {
670670 $movies = Movie::where('title', 'Carrie')
671- ->readPreference('secondaryPreferred' )
671+ ->readPreference(ReadPreference::SECONDARY_PREFERRED )
672672 ->get();
673673
674674 return view('browse_movies', [
Original file line number Diff line number Diff line change 77use App \Models \Movie ;
88use Illuminate \Support \Facades \DB ;
99use MongoDB \Laravel \Tests \TestCase ;
10+ use MongoDB \Driver \ReadPreference ;
1011
1112class ReadOperationsTest extends TestCase
1213{
@@ -175,7 +176,7 @@ public function testReadPreference(): void
175176 {
176177 // start-read-pref
177178 $ movies = Movie::where ('title ' , 'Carrie ' )
178- ->readPreference (' secondaryPreferred ' )
179+ ->readPreference (ReadPreference:: SECONDARY_PREFERRED )
179180 ->get ();
180181 // end-read-pref
181182
Original file line number Diff line number Diff line change @@ -1044,8 +1044,9 @@ set members by setting a read preference.
10441044
10451045The following example queries the ``movies`` collection for documents
10461046in which the ``runtime`` value is greater than ``240``. The example passes a
1047- value of ``"secondary"`` to the ``readPreference()`` method, which sends
1048- the query to secondary replica set members:
1047+ value of ``ReadPreference::SECONDARY_PREFERRED`` to the ``readPreference()``
1048+ method, which sends the query to secondary replica set members
1049+ or the primary member if no secondaries are available:
10491050
10501051.. literalinclude:: /includes/query-builder/QueryBuilderTest.php
10511052 :language: php
You can’t perform that action at this time.
0 commit comments