title: Symfony - update multiple records
body: <p>What is the best way to update multiple records in database using doctrine, symfony2?</p>
  
  <p>I receive array of records ids which I have to update.<br>
  I want to assign to each record its index from received array to column show_order.
  So if i receive array $array = array(22, 1, 5, 10) then I want to do</p>
  
  <pre><code> $i = 0;
   foreach($array as $a) {
      $record = $this-&gt;getDoctrine-&gt;getRepository('AcmeBundle:SomeEntity')-&gt;findOneById($a);
      if ($record != null) $record-&gt;setOrder($i++);
   }
   $this-&gt;getDoctrine()-&gt;getEntityManager()-&gt;flush();
  </code></pre>
  
  <p>but it's horrible way, because for each record I do one SELECT, so number of queries is O(n).</p>
  
  <p>How to do it better?</p>