@@ -381,6 +381,41 @@ wildcard characters:
381
381
...
382
382
]
383
383
384
+ whereLike() and whereNotLike() Methods
385
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
386
+
387
+ You can perform queries to match string patterns by using the
388
+ following methods:
389
+
390
+ - ``whereLike()``: Matches a specified pattern. By default, this method
391
+ performs a case-insensitive match. You can enable case-sensitivity by
392
+ passing ``true`` as the last parameter to the method.
393
+ - ``whereNotLike()``: Matches documents in which the field
394
+ value does not contain the specified string pattern.
395
+
396
+ The following example shows how to use the ``whereLike()`` method to
397
+ match documents in which the ``title`` field has a value that matches the
398
+ pattern ``'Start%'`` with case-sensitivity enabled:
399
+
400
+ .. io-code-block::
401
+ :copyable: true
402
+
403
+ .. input:: /includes/query-builder/QueryBuilderTest.php
404
+ :language: php
405
+ :dedent:
406
+ :start-after: begin query whereLike
407
+ :end-before: end query whereLike
408
+
409
+ .. output::
410
+ :language: json
411
+ :visible: false
412
+
413
+ [
414
+ { "title": "Start-Up", ... },
415
+ { "title": "Start the Revolution Without Me", ... },
416
+ ...
417
+ ]
418
+
384
419
.. _laravel-query-builder-distinct:
385
420
386
421
Retrieve Distinct Values
@@ -847,45 +882,6 @@ To learn more about regular expression queries in MongoDB, see
847
882
:manual:`$regex </reference/operator/query/regex/>`
848
883
in the {+server-docs-name+}.
849
884
850
- whereLike() and whereNotLike() Methods
851
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
852
-
853
- You can perform queries to match string patterns by using the
854
- following methods:
855
-
856
- - ``whereLike()``: Matches a specified pattern. By default, this method
857
- performs a case-insensitive match. You can enable case-sensitivity by
858
- passing ``true`` as the last parameter to the method.
859
- - ``whereNotLike()``: Matches documents in which the field
860
- value does not contain the specified string pattern.
861
-
862
- The following example shows how to use the ``whereLike()`` method to
863
- match documents in which the ``title`` field has a value that matches the
864
- pattern ``'Start%'`` with case-sensitivity enabled:
865
-
866
- .. literalinclude:: /includes/query-builder/QueryBuilderTest.php
867
- :language: php
868
- :dedent:
869
- :start-after: begin query whereLike
870
- :end-before: end query whereLike
871
-
872
- The preceding query matches documents with the following ``title``
873
- field values:
874
-
875
- .. code-block:: none
876
-
877
- Start-Up
878
- Start the Revolution Without Me
879
- Starting Over
880
-
881
- The query doesn't match the following ``title`` values:
882
-
883
- .. code-block:: none
884
-
885
- Restart
886
- starting over
887
- I Start Counting
888
-
889
885
.. _laravel-query-builder-whereRaw:
890
886
891
887
Run MongoDB Query API Operations Example
0 commit comments