title: Why am I unable to find a record by _id in mongodb
body: <p>I am trying to find a record in mongoDB by it's MongoID "_id" field.   I have found examples on how to do it, but can not get it to work. Example:</p>
  
  <pre><code>$recID = "010101010101011";  //would be a valid mongodb _id
  $recID = new MongoId((string)$recID);  // I have tried it without the (string) cast too
  $cursor = $this-&gt;Collection-&gt;findOne(array('_id' =&gt; $recID));
  print_r($cursor);
  </code></pre>
  
  <p>It outputs:</p>
  
  <pre><code>MongoCursor (
  )
  </code></pre>
  
  <p>Nothing inside.</p>
  
  <p>I have verified everything else is working by changing the "_id" above to a different field such as "firstName" and passing in a first name and I get back valid data.</p>
  
  <p>Why does this not work?</p>
  
  <p>I have even tried searching with $recID as a string, no difference.</p>
  
  <p>Here is what happens from the mongo shell (though I am not sure if I am querying properly):</p>
  
  <pre><code>&gt;
  &gt; db.Employee.find({login:"myperson"})
  { "_explicitType" : "project.Employee", "_id" : ObjectId("4e209564203d83940f0000
  06"), "active" : true, "addedDate" : "07/15/2011 15:29:21", "domain" : "xxx",
   "id" : ObjectId("4e209564203d83940f000006"), "lastLogin" : "07/20/2011 19:13:36
  ", "login" : "myperson", "name" : "My Person", "pw" : "", "ulevel" : 9999
  }
  &gt; db.Employee.find({id:"4e209564203d83940f000006"})
  &gt; db.Employee.find({_id:"4e209564203d83940f000006"})
  &gt;
  </code></pre>
  
  <p>Notice nothing returned for id or _id.</p>