September 2018
Beginner to intermediate
192 pages
4h 37m
English
As with queries, when performing updates, PHPLIB closely mirrors the JavaScript equivalent. Thus, the following methods are available:
In this example, we will use the same filter as we did previously (the ObjectID for the customer Spencer Sanford) and update the balance:
// here is the JavaScript query we wish to emulate: // db.customers.updateOne( // {_id:ObjectId("5b47108b533b8406ac227798")}, // {$set:{balance:99.99}} // ); $filter = ['_id' => new ObjectId('5b47108b533b8406ac227798')]; try { $document = $collection->findOne($filter); printf("Name: ...Read now
Unlock full access