exit; } try { $result = $collection->updateMany(["citizen" => "Iceland"], ['$set' => ["viking" => true]]); printf("Updated: %d (out of expected 2), verify Icelandic people are vikings\n", $result->getModifiedCount()); $result = $collection->find(); foreach ($result as $document) { var_dump($document); } echo "\n"; } catch (Exception $e) { printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__); exit; } try { $result = $collection->replaceOne(["nick" => "Bobby Fischer"], ["name" => "Magnus Carlsen", "nick" => "unknown", "citizen" => "Norway"]); printf("Replaced: %d (out of expected 1), verify Bobby has been replaced with Magnus\n", $result->getModifiedCount()); $result = $collection->find(); foreach ($result as $document) { var_dump($document); } echo "\n"; } catch (Exception $e) { printf("Caught exception '%s', on line %d\n", $e->getMessage(), __LINE__); exit; } try { $result = $collection->deleteOne($document); printf("Deleted: %d (out of expected 1)\n\n", $result->getDeletedCount()); $result = $collection->deleteMany(["citizen" => "Iceland"]); printf("Deleted: %d (out of expected 2)\n\n", $result->getDeletedCount());