Created
June 20, 2017 14:08
-
-
Save adam-hert/1af9ee78f8bf953c66903e5d76942172 to your computer and use it in GitHub Desktop.
test mongo
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 | |
oboe_log(null, 'info', array('Controller' => 'My_controller','Action' => 'my_action')); | |
// connect | |
$m = new Mongo(); | |
// select a database | |
$db = $m->training; | |
$coll = $db->messages; | |
for ($i = 0; $i < 10; $i = $i + 1) { | |
$coll->insert( array( "text" => "Hello World", "n" => $i ) ); | |
} | |
$cursor = $coll->find(); | |
foreach ($cursor as $obj) { | |
print $obj['_id'] . "\n"; | |
print print_r( $obj ) . "\n"; | |
} | |
print "\nCount " . $coll->count() . "\n"; | |
$coll->remove(); | |
print "\nCount " . print_r( $db->command( array( "count" => "messages" ) )) . "\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment