Last active
November 13, 2018 06:26
-
-
Save bjpeterdelacruz/eaa2dc7db0c6f1465ceed658e2f01f31 to your computer and use it in GitHub Desktop.
Inserting a document into MongoDB database (PHP 5 vs. PHP 7)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PHP 5 | |
$m = new MongoClient(); | |
$db = $m->test; | |
$collection = $db->todos; | |
$collection->insert(array("name" => $name)); | |
// PHP 7 | |
$m = new MongoDB\Driver\Manager(); | |
$bulk = new MongoDB\Driver\BulkWrite; | |
$bulk->insert(array("name" => $name)); | |
$m->executeBulkWrite('test.todos', $bulk); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment