title: How to remove a document referenced by an id in mongoDB from php?
body: <p>I was successful in deleting documents using other fields but could not delete using "_id" field. The PHP page says that the id should be a string (which it is by default), but what I was trying to do is, giving an id of my own which is an integer, and am doing the following:</p>
  
  <p>This is my document structure:</p>
  
  <pre><code>$document = array (
      '_id' =&gt; new MongoInt32(1),
      'cust_id' =&gt; 'abc124'
  )
  </code></pre>
  
  <p>This is how I am trying to delete:</p>
  
  <pre><code>$collection-&gt;remove(array('_id' =&gt; new MongoId(1)), true);
  </code></pre>
  
  <p>But this is giving me an error. PHP php manual says:</p>
  
  <blockquote>
    <p>"To remove a document based on its ID, you need to ensure that you pass the ID as a MongoID object rather than just a string:"</p>
  </blockquote>
  
  <p>But my id is a int and I cant figure out the process to delete the document referenced by the id.</p>
  
  <p>Your help would be appreciated. Thank You.</p>