title: using php to fetch a record based on "_id" from mongo db
body: <p>I am trying to fetch a record from mongo db using php. I am trying to use _id field in the mongo collection to access the record. But i am unable to fetch the corresponding record and i am only getting null. This is the code i am using.</p>
  
  <pre><code>$db =  $this-&gt;Generalmodel-&gt;connect();
  $collection = $db-&gt;listing;
  $cursor = $collection-&gt;findOne(array("_id"=&gt;$id));
  var_dump($cursor);
  </code></pre>
  
  <p>I also tried it with the following and is of no use too</p>
  
  <pre><code>$collection = $db-&gt;listing;
  $cursor = $collection-&gt;find(array( '$and' =&gt; array( array('_id' =&gt; $id), array('blocked' =&gt; "0"))));
  foreach ($cursor as $obj)
  var_dump($obj)
  </code></pre>
  
  <p>Am i missing something here?</p>