title: delete several rows where attribute = x
body: <p>I need to delete all rows where the image_id = x applies
  like this </p>
  
  <pre><code>DELETE FROM  `ImageVoters` WHERE image_id =1
  </code></pre>
  
  <p>How do I do this using DQL?</p>
  
  <p>Since im trying to delete several rows at once the remove() function won't work</p>
  
  <pre><code>EntityManager#remove() expects parameter 1 to be an entity object, array given.
  
   $em = $this-&gt;getDoctrine()-&gt;getManager();
   $query = $em-&gt;createQuery('SELECT u FROM GabrielUploadBundle:ImageVoters u WHERE u.image_id = 1');
   $db_imageactions = $query-&gt;getResult();
   $em-&gt;remove($db_imageactions);
   $em-&gt;flush();
  </code></pre>
  
  <p>This is the code that works</p>
  
  <pre><code>    $qb = $em-&gt;createQueryBuilder();
      $qb-&gt;delete('GabrielUploadBundle:ImageVoters', 'v')
          -&gt;where($qb-&gt;expr()-&gt;eq('v.image_id', ':imageId'))
          -&gt;setParameter('imageId', $current_imageId);
  
      $qb-&gt;getQuery()-&gt;execute();
  </code></pre>