title: Deleting on a field other than the primary id
body: <p>I am trying to delete a list of entries form my table corresponding to a particular id. I get the id and post it through an ajax function to the controller and use the Delete function of the model to delete the particular entry. But the entries are not deleted.</p>
  
  <p>This is my ajax function in the view file called reports.ctp where I call the controller function when a link is clicked. </p>
  
  <pre><code>$(".delete_entries").click(function() {
      $.ajax({
          type: "POST",
          url: "http://localhost/FormBuilder/reports/deleteEntries",
          data: "formid="+formid,
          async: false,
          success: function(msg){
              alert( "Data Saved: " + msg);
          }  
      });//ajax
  });
  </code></pre>
  
  <p>This is the delete action in the reports_controller.php</p>
  
  <pre><code>function deleteEntries()
  {
      $this-&gt;data['Result']['form_id']=$this-&gt;params['form']['formid'];
      $this-&gt;Report-&gt;Result-&gt;delete($this-&gt;data['Result']['form_id']);
  }
  </code></pre>
  
  <p>The table from which I want to delete the entries is 'Results'. some one help me as to how to delete the entries. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Now I'm using the delete sql query as such to delete the entries in the Results table.</p>
  
  <pre><code>$this-&gt;Result-&gt;query("delete from results where form_id=".$this-&gt;data['Result']['form_id']);
  </code></pre>
  
  <p>I do not know why the delete command of CakePHP doesn't work. </p>
  
  <p>But now the problem is, only when I refresh the page, the deletion of the entries are reflected. If I do not refresh, the entries are still displayed in the table.
  Maybe if the delete function of CakePHP works, the page will get refreshed.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>The deleteAll method works since I'm not giving the primary id as the input for the delete method as deceze has pointed out.</p>
  
  <p>$this->Result->deleteAll(array('Result.form_id' => $this->data['Result']['form_id']));</p>
  
  <p>Regarding the problem of reflecting the deletion of entries, I did a $(".entries).remove() on success as Xr had suggested, so the table of entries is removed without having to do a page refresh.</p>