-
Notifications
You must be signed in to change notification settings - Fork 34
DOCSP-41973 Read Landing Page #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lindseymoore
merged 9 commits into
mongodb:php-standardization
from
lindseymoore:DOCSP-41973
Sep 26, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a5f2990
DOCSP-41973 Read Landing Page
lindseymoore f11a302
full page with ex
lindseymoore fc6dfda
add page
lindseymoore 1680c76
meta
lindseymoore e236d7a
edit sample app intro
lindseymoore ac0e57d
change links in count sections
lindseymoore 23738fd
update sample app intro
lindseymoore 36b360c
tech review
lindseymoore 63c1926
Merge branch 'php-standardization' into DOCSP-41973
lindseymoore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
use MongoDB\Client; | ||
|
||
$uri = getenv('MONGODB_URI') ?: throw new RuntimeException('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset'); | ||
$client = new MongoDB\Client($uri); | ||
|
||
$collection = $client->sample_mflix->movies; | ||
|
||
// Find One | ||
// start-find-one | ||
$document = $collection->findOne(['year' => 1994]); | ||
echo json_encode($document) , "\n"; | ||
// end-find-one | ||
|
||
// Find Multiple | ||
// start-find-multiple | ||
$resultsMultiple = $collection->find(['year' => 1970]); | ||
foreach ($resultsMultiple as $doc) { | ||
echo json_encode($doc) , "\n"; | ||
} | ||
// end-find-multiple | ||
|
||
// Count Document | ||
// start-count | ||
$result = $collection->countDocuments([]); | ||
echo "Number of documents: " . $result; | ||
// end-count | ||
|
||
// Count Specific Documents | ||
// start-count-specific | ||
$result = $collection->countDocuments(['year' => 2010]); | ||
echo "Number of companies founded in 2010: " . $result; | ||
// end-count-specific | ||
|
||
// Estimated Count | ||
// start-count-estimate | ||
$result = $collection->estimatedDocumentCount(); | ||
echo "Estimated number of documents: " . $result; | ||
// end-count-estimate | ||
|
||
// Distinct Values | ||
// start-distinct | ||
$results = $collection->distinct('year'); | ||
foreach ($results as $value) { | ||
echo json_encode($value) . PHP_EOL; | ||
} | ||
// end-distinct | ||
|
||
// Data Changes | ||
// start-change-stream | ||
$changeStream = $collection->watch(); | ||
|
||
for ($changeStream->rewind(); true; $changeStream->next()) { | ||
if ( ! $changeStream->valid()) { | ||
continue; | ||
} | ||
$event = $changeStream->current(); | ||
echo toJSON($event) . PHP_EOL; | ||
|
||
if ($event['operationType'] === 'invalidate') { | ||
break; | ||
} | ||
} | ||
// end-change-stream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do...while
would be more appropriate.Have you looked at our changestream example?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of time and for consistency with examples on the already approved Monitor Data Changes page, I'll keep as is here. I can look into revising the examples as you've suggested here in a future piece of work. Thanks!
Ticket: https://jira.mongodb.org/browse/DOCSP-43912