Skip to content

Commit 0c046d6

Browse files
committed
Merge branch 'v1.8'
* v1.8: Update tested driver versions PHPLIB-577: Add examples for aggregation methods (#797) Fixed missing backslash in documentation (#794)
2 parents 41cf16c + 953dbc1 commit 0c046d6

File tree

6 files changed

+41
-9
lines changed

6 files changed

+41
-9
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ axes:
439439
variables:
440440
DRIVER_VERSION: "1.8.1"
441441
- id: "latest-stable"
442-
display_name: "1.8-stable"
442+
display_name: "1.9-stable"
443443
variables:
444444
DRIVER_VERSION: "stable"
445445
- id: "1.8-dev"

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,13 @@ jobs:
5151
# Test against PHP 8
5252
- stage: Test
5353
php: "8.0snapshot"
54-
env:
55-
- DRIVER_VERSION="1.9.0RC1"
5654
- stage: Test
5755
php: "8.0snapshot"
5856
env:
59-
- DRIVER_VERSION="1.9.0RC1"
6057
- DEPLOYMENT=REPLICASET
6158
- stage: Test
6259
php: "8.0snapshot"
6360
env:
64-
- DRIVER_VERSION="1.9.0RC1"
6561
- DEPLOYMENT=SHARDED_CLUSTER_RS
6662

6763
before_install:

docs/reference/method/MongoDBCollection-aggregate.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,25 @@ MongoDB server version and whether the ``useCursor`` option is specified. If
5858
``result`` array from the command response document. In both cases, the return
5959
value will be :php:`Traversable <traversable>`.
6060

61-
.. todo: add examples
61+
Examples
62+
--------
63+
64+
The following aggregation example uses a collection called ``names`` and groups
65+
the ``first_name`` field together, counts the total number of results in each
66+
group, and sorts the results by name.
67+
68+
.. code-block:: php
69+
70+
<?php
71+
72+
$collection = (new MongoDB\Client)->test->names;
73+
74+
$cursor = $collection->aggregate(
75+
[
76+
['$group' => ['_id' => '$first_name', 'name_count' => ['$sum' => 1]]],
77+
['$sort' => ['_id' => 1]],
78+
]
79+
);
6280

6381
See Also
6482
--------

docs/reference/method/MongoDBDatabase-aggregate.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,25 @@ Errors/Exceptions
5151

5252
.. _php-db-agg-method-behavior:
5353

54-
.. todo: add examples
54+
Examples
55+
--------
56+
57+
The following aggregation example lists all running commands using the
58+
``$currentOp`` aggregation pipeline stage, then filters this list to only show
59+
running command operations.
60+
61+
.. code-block:: php
62+
63+
<?php
64+
65+
$database = (new MongoDB\Client)->admin;
66+
67+
$cursor = $database->aggregate(
68+
[
69+
['$currentOp' => []],
70+
['$match' => ['op' => 'command'],
71+
]
72+
);
5573

5674
See Also
5775
--------

docs/tutorial/collation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ group, and sorts the results by German phonebook order.
360360

361361
<?php
362362

363-
$collection = (new MongoDB\Client)->test->recipes;
363+
$collection = (new MongoDB\Client)->test->names;
364364

365365
$cursor = $collection->aggregate(
366366
[

docs/tutorial/custom-types.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ to convert to BSON and store in the database. That data will later be used to
2323
reconstruct the object upon reading from the database.
2424

2525
As an example we present the ``LocalDateTime`` class. This class wraps around
26-
the :php:`MongoDB\\BSON\UTCDateTime <class.mongodb-bson-utcdatetime>` data
26+
the :php:`MongoDB\\BSON\\UTCDateTime <class.mongodb-bson-utcdatetime>` data
2727
type and a time zone.
2828

2929
.. code-block:: php

0 commit comments

Comments
 (0)