Skip to content

PHPLIB-987: Add more examples #981

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
merged 12 commits into from
Oct 4, 2022
Merged

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Sep 28, 2022

PHPLIB-987

This PR adds more examples for every-day use of the PHP library. New examples:

  • bulk writes (this shows the syntax for each bulk write operation)
  • with_transaction helper
  • Aggregation pipeline
  • Serialisation and Deserialisation using MongoDB\BSON\Persistable
  • Deserialisation using typeMap and MongoDB\BSON\Unserializable

The first commit in the PR fixes an issue where running the example code from outside of the examples directory causes fatal errors.

@alcaeus alcaeus requested a review from jmikola September 28, 2022 13:40
@alcaeus alcaeus self-assigned this Sep 28, 2022
@alcaeus alcaeus requested a review from jmikola September 29, 2022 08:29
@@ -71,7 +70,7 @@ function toJSON(object $document): string
]
);

$cursor = $collection->find([], ['batchSize' => 2]);
$cursor = $collection->find([]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, Collection::find() can be called without arguments as $filter defaults to an empty array. This technically violates the CRUD spec but we snuck that past the goalie long ago. Up to you if you'd like to keep this as-is or change to find().

Likewise in with_transaction.php.

@alcaeus alcaeus force-pushed the phplib-987-examples branch from f1913ea to 28efb21 Compare October 2, 2022 09:36
@alcaeus alcaeus force-pushed the phplib-987-examples branch from 28efb21 to fb314f5 Compare October 4, 2022 05:59
@alcaeus alcaeus merged commit 8a32752 into mongodb:master Oct 4, 2022
@alcaeus alcaeus deleted the phplib-987-examples branch October 7, 2022 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants