Created
September 12, 2016 23:44
-
-
Save thomaslorentsen/1a52eae14721b94ae97d47b665448307 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
require 'vendor/autoload.php'; | |
$manager = new MongoDB\Driver\Manager("mongodb://192.168.33.96:27017"); | |
$collection = new MongoDB\Collection($manager, "phplib_demo.write", 'test'); | |
$result = $collection->insertOne(array( | |
'firstname' => 'hello', | |
'lastname' => 'world', | |
)); | |
$result = $collection->insertOne(array( | |
'firstname' => 'onetwothreefour', | |
'lastname' => 'bbb', | |
)); | |
printf("Inserted _id: %s\n\n", $result->getInsertedId()); | |
$cursor = $collection->find( | |
["firstname" => new \MongoDB\BSON\Regex('four', 'is')], | |
['comment' => 'test query'] | |
); | |
foreach($cursor as $document) { | |
var_dump($document); | |
} | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment