Skip to content

Instantly share code, notes, and snippets.

@adam-hert
Created June 20, 2017 14:08
Show Gist options
  • Save adam-hert/1af9ee78f8bf953c66903e5d76942172 to your computer and use it in GitHub Desktop.
Save adam-hert/1af9ee78f8bf953c66903e5d76942172 to your computer and use it in GitHub Desktop.
test mongo
<?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