Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
2f8a6e5f
Commit
2f8a6e5f
authored
Jan 26, 2017
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #337
parents
c346c345
bb7d5d52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
crud.txt
docs/tutorial/crud.txt
+42
-0
No files found.
docs/tutorial/crud.txt
View file @
2f8a6e5f
...
@@ -331,6 +331,48 @@ The output would then resemble::
...
@@ -331,6 +331,48 @@ The output would then resemble::
10025: NEW YORK, NY
10025: NEW YORK, NY
90201: BELL GARDENS, CA
90201: BELL GARDENS, CA
Regular Expressions
~~~~~~~~~~~~~~~~~~~
Filter criteria may include regular expressions, either by using the
:php:`MongoDB\\BSON\\Regex <mongodb-bson-regex>` class directory or the
:query:`$regex` operator.
The following example lists documents in the ``zips`` collection where the city
name starts with "garden" and the state is Texas:
.. code-block:: php
<?php
$collection = (new MongoDB\Client)->demo->zips;
$cursor = $collection->find([
'city' => new MongoDB\BSON\Regex('^garden', 'i'),
'state' => 'TX',
]);
foreach ($cursor as $document) {
printf("%s: %s, %s\n", $document['_id'], $document['city'], $document['state']);
}
The output would then resemble::
78266: GARDEN RIDGE, TX
79739: GARDEN CITY, TX
79758: GARDENDALE, TX
An equivalent filter could be constructed using the :query:`$regex` operator:
.. code-block:: php
[
'city' => ['$regex' => '^garden', '$options' => 'i'],
'state' => 'TX',
]
.. seealso:: :manual:`$regex </reference/operator/query/regex>` in the MongoDB manual
Complex Queries with Aggregation
Complex Queries with Aggregation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment