title: Multiple update queries in doctrine and symfony2
body: <p>I've tried to do this in several ways but i can't find the exact syntax for it to work. My latest attempt is below (in a Symfony2 Entity Repository class):</p>
  
  <pre><code>public function updateOrdering($new_order, $evaluation_id)
  {
      $qb = $this-&gt;createQueryBuilder('IddpRplusBundle:Answer');
      foreach($new_order as $item){
          $id = $item['id'];
          $answernr = $item['answernr'];
          $q = $qb-&gt;update('IddpRplusBundle:Answer a')
                  -&gt;set('a.answernr', $answernr)
                  -&gt;where('a.id = :id')
                  -&gt;getQuery()
                  -&gt;execute()
                  ;
      }
  }
  </code></pre>
  
  <p>The error is " <strong>Invalid parameter number: number of bound variables does not match number of tokens</strong>".. And I would also like to add a second where clause</p>
  
  <pre><code>-&gt;where('a.evaluation_id = :evaluation_id')
  </code></pre>
  
  <p>which is a foreign key in the mysql table but then the error changes to "can't find the evaluation_id field" even though it exists in the table itself (the relationship between evaluation and answer entities is one to many and it's mapped as such in the entities as well)</p>
  
  <p>Any ideas?</p>
  
  <p>[UPDATE]</p>
  
  <p>There was a gotcha in the solution below. I also had to add a call to flush or it would start accumulating the update field like this "update answer set answernr=1, answernr=2 where id=2". So the final solution was:</p>
  
  <pre><code>-&gt;set('a.answernr', (int)$answernr + (int)$start)
  -&gt;where('a.id = :id AND a.evaluation = :evaluation_id ')
                  -&gt;setParameters(array('id' =&gt; $id,'evaluation_id' =&gt; $evaluation_id))
                  -&gt;getQuery()
                  -&gt;execute()
                  ;
          $this-&gt;_em-&gt;flush();
  </code></pre>