title: Delete record from many to many entity in Zend using Doctrine 2
body: <p>I am working on Zend Doctrine. I have a many-to-many entity <code>groups_contacts</code> which has fields <code>group_id</code> and <code>contact_id</code> linked to relevant tables <code>group</code> and <code>contact</code> and created in <code>group</code> entity.</p>
  
  <p>I am creating <code>groups_contacts</code> in <code>group</code> entity which is a many-to-many relationship.</p>
  
  <p>Following is the code of delete action:</p>
  
  <pre><code>public function deleteGroupMemberAction() {
      $auth_service = $this-&gt;getServiceLocator()-&gt;get('doctrine.authenticationservice.orm_default');
      $objectManager = $this-&gt;getServiceLocator()-&gt;get('Doctrine\ORM\EntityManager');
      $em = $this-&gt;getServiceLocator()-&gt;get('doctrine.entitymanager.orm_default');
      $user = $auth_service-&gt;getIdentity();
      //die($_POST['g_id'] . ' removed');
  
      $query_deleteMember = $em-&gt;createQuery('delete from groups_contacts gc where gc.contact_id = 7 and gc.group_id = 1');
  
      $numDeleted = $query_deleteMember-&gt;execute();
      die($query_deleteMember. ' removed');
  
      $objectManager-&gt;flush();
      die($title . ' removed');
  }
  </code></pre>
  
  <p>This function called on ajax call which is working perfectly.</p>
  
  <p>I don't know why the delete query is not working, I tried other ways but get the same result. Does anyone have any ideas?</p>