Skip to content

Commit 1f4beb1

Browse files
committed
JT feedback
1 parent 6eecf24 commit 1f4beb1

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

source/includes/read/project.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
require 'vendor/autoload.php';
44

5-
use MongoDB\Client;
6-
7-
$client = new Client('<connection string>');
5+
$uri = getenv('MONGODB_URI') ?: throw new RuntimeException('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset');
6+
$client = new MongoDB\Client($uri);
87

98
// start-db-coll
10-
$db = $client->sample_restaurants;
11-
$collection = $db->restaurants;
9+
$collection = $client->sample_restaurants->restaurants;
1210
// end-db-coll
1311

1412
// Retrieves documents matching the "name" field query and projects their "name", "cuisine", and "borough" values
@@ -59,5 +57,3 @@
5957
echo json_encode($doc) . PHP_EOL;
6058
}
6159
// end-project-exclude
62-
63-
?>

source/includes/read/retrieve.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
$client = new MongoDB\Client($uri);
66

77
// start-db-coll
8-
$db = $client->sample_training;
9-
$collection = $db->companies;
8+
$collection = $client->sample_training->companies;
109
// end-db-coll
1110

1211
// Finds one document with a "name" value of "LinkedIn"

source/read/project.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Sample Data
3030
The examples in this guide use the ``restaurants`` collection in the ``sample_restaurants``
3131
database from the :atlas:`Atlas sample datasets </sample-data>`. To access this collection
3232
from your PHP application, instantiate a ``MongoDB\Client`` that connects to an Atlas cluster
33-
and assign the following values to your ``db`` and ``collection`` variables:
33+
and assign the following value to your ``collection`` variable:
3434

3535
.. literalinclude:: /includes/read/project.php
3636
:language: php

source/read/retrieve.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Sample Data
3131
The examples in this guide use the ``companies`` collection in the ``sample_training``
3232
database from the :atlas:`Atlas sample datasets </sample-data>`. To access this collection
3333
from your PHP application, instantiate a ``MongoDB\Client`` that connects to an Atlas cluster
34-
and assign the following values to your ``db`` and ``collection`` variables:
34+
and assign the following value to your ``collection`` variable:
3535

3636
.. literalinclude:: /includes/read/retrieve.php
3737
:language: php

0 commit comments

Comments
 (0)