File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 2626// Converts the documents stored in a cursor to an array
2727// start-cursor-array
2828$ cursor = $ collection ->find (['name ' => 'Dunkin \' Donuts ' ]);
29- $ array_results = $ cursor ->toArray ();
29+ $ resultArray = $ cursor ->toArray ();
3030// end-cursor-array
3131
3232// Creates a collection with a maximum size and inserts documents representing vegetables
5252$ cursor = $ collection ->find ([], ['cursorType ' => MongoDB \Operation \Find::TAILABLE ]);
5353$ cursor ->rewind ();
5454
55- $ docs_found = 0 ;
56- while ($ docs_found < 3 ) {
55+ $ docsFound = 0 ;
56+ while ($ docsFound < 3 ) {
5757 if ($ cursor ->valid ()) {
5858 $ doc = $ cursor ->current ();
5959 echo json_encode ($ doc ), PHP_EOL ;
60- $ docs_found ++;
60+ $ docsFound ++;
6161 }
6262 $ cursor ->next ();
6363}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ function toJSON(object $document): string
2121
2222// Creates or references a GridFS bucket with a custom name
2323// start-create-custom-bucket
24- $ custom_bucket = $ client ->db ->selectGridFSBucket (
24+ $ customBucket = $ client ->db ->selectGridFSBucket (
2525 ['bucketName ' => 'myCustomBucket ' ],
2626);
2727// end-create-custom-bucket
@@ -44,8 +44,8 @@ function toJSON(object $document): string
4444// Prints information about each file in the bucket
4545// start-retrieve-file-info
4646$ files = $ bucket ->find ();
47- foreach ($ files as $ file_doc ) {
48- echo toJSON ($ file_doc ), PHP_EOL ;
47+ foreach ($ files as $ fileDocument ) {
48+ echo toJSON ($ fileDocument ), PHP_EOL ;
4949}
5050// end-retrieve-file-info
5151
Original file line number Diff line number Diff line change 99// end-db-coll
1010
1111// start-replace-one
12- $ replace_document = [
12+ $ replaceDocument = [
1313 'name ' => 'Mongo \'s Pizza ' ,
1414 'cuisine ' => 'Pizza ' ,
1515 'address ' => [
1919 'borough ' => 'Manhattan ' ,
2020];
2121
22- $ result = $ collection ->replaceOne (['name ' => 'Pizza Town ' ], $ replace_document );
22+ $ result = $ collection ->replaceOne (['name ' => 'Pizza Town ' ], $ replaceDocument );
2323echo 'Modified documents: ' , $ result ->getModifiedCount ();
2424// end-replace-one
2525
2626// start-replace-options
27- $ replace_document = [
27+ $ replaceDocument = [
2828 'name ' => 'Food World ' ,
2929 'cuisine ' => 'Mixed ' ,
3030 'address ' => [
3636
3737$ result = $ collection ->replaceOne (
3838 ['name ' => 'Food Town ' ],
39- $ replace_document ,
39+ $ replaceDocument ,
4040 ['upsert ' => true ],
4141);
4242// end-replace-options
You can’t perform that action at this time.
0 commit comments