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 26
26
// Converts the documents stored in a cursor to an array
27
27
// start-cursor-array
28
28
$ cursor = $ collection ->find (['name ' => 'Dunkin \' Donuts ' ]);
29
- $ array_results = $ cursor ->toArray ();
29
+ $ resultArray = $ cursor ->toArray ();
30
30
// end-cursor-array
31
31
32
32
// Creates a collection with a maximum size and inserts documents representing vegetables
52
52
$ cursor = $ collection ->find ([], ['cursorType ' => MongoDB \Operation \Find::TAILABLE ]);
53
53
$ cursor ->rewind ();
54
54
55
- $ docs_found = 0 ;
56
- while ($ docs_found < 3 ) {
55
+ $ docsFound = 0 ;
56
+ while ($ docsFound < 3 ) {
57
57
if ($ cursor ->valid ()) {
58
58
$ doc = $ cursor ->current ();
59
59
echo json_encode ($ doc ), PHP_EOL ;
60
- $ docs_found ++;
60
+ $ docsFound ++;
61
61
}
62
62
$ cursor ->next ();
63
63
}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ function toJSON(object $document): string
21
21
22
22
// Creates or references a GridFS bucket with a custom name
23
23
// start-create-custom-bucket
24
- $ custom_bucket = $ client ->db ->selectGridFSBucket (
24
+ $ customBucket = $ client ->db ->selectGridFSBucket (
25
25
['bucketName ' => 'myCustomBucket ' ],
26
26
);
27
27
// end-create-custom-bucket
@@ -44,8 +44,8 @@ function toJSON(object $document): string
44
44
// Prints information about each file in the bucket
45
45
// start-retrieve-file-info
46
46
$ 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 ;
49
49
}
50
50
// end-retrieve-file-info
51
51
Original file line number Diff line number Diff line change 9
9
// end-db-coll
10
10
11
11
// start-replace-one
12
- $ replace_document = [
12
+ $ replaceDocument = [
13
13
'name ' => 'Mongo \'s Pizza ' ,
14
14
'cuisine ' => 'Pizza ' ,
15
15
'address ' => [
19
19
'borough ' => 'Manhattan ' ,
20
20
];
21
21
22
- $ result = $ collection ->replaceOne (['name ' => 'Pizza Town ' ], $ replace_document );
22
+ $ result = $ collection ->replaceOne (['name ' => 'Pizza Town ' ], $ replaceDocument );
23
23
echo 'Modified documents: ' , $ result ->getModifiedCount ();
24
24
// end-replace-one
25
25
26
26
// start-replace-options
27
- $ replace_document = [
27
+ $ replaceDocument = [
28
28
'name ' => 'Food World ' ,
29
29
'cuisine ' => 'Mixed ' ,
30
30
'address ' => [
36
36
37
37
$ result = $ collection ->replaceOne (
38
38
['name ' => 'Food Town ' ],
39
- $ replace_document ,
39
+ $ replaceDocument ,
40
40
['upsert ' => true ],
41
41
);
42
42
// end-replace-options
You can’t perform that action at this time.
0 commit comments