Skip to content

Instantly share code, notes, and snippets.

@gatesvp
Created May 10, 2011 00:09
Show Gist options
  • Save gatesvp/963686 to your computer and use it in GitHub Desktop.
Save gatesvp/963686 to your computer and use it in GitHub Desktop.
Sample with isset
<?php
try{
$m = new Mongo('localhost');
$db = $m->abc;
$collection = $db->def;
$collection->drop();
// Insert test data
$collection->insert( array('A' => 1, 'B' => 4, 'C' => array("C1" => 'val', "C2" => 15) ) );
$collection->insert( array('A' => 2, 'B' => 5 ) );
$cursor = $collection->find();
foreach($cursor as $data){
if(isset($data['C'])){
print_r($data['C']);
}
}
}
catch(Exception $e){
print_r($e->getMessage());
print("\n");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment