title: Symfony2 Doctrine iterate over with while next()
body: <p>I'm looking for a <strong>working solution</strong>, to iterate over a <a href="/questions/tagged/mongodb" class="post-tag" title="show questions tagged &#39;mongodb&#39;" rel="tag">mongodb</a> <code>PersistentCollection</code> in <a href="/questions/tagged/symfony2" class="post-tag" title="show questions tagged &#39;symfony2&#39;" rel="tag">symfony2</a>. Unfortunately this seems not to work? <strong>Symfony ignores</strong> the <code>next()</code> function!</p>
  
  <pre><code>while (($animal = $zooAnimals-&gt;next()) !== false) {
  
      $color = $animal-&gt;getColor();
  
      print_r($color); die; // Test and die
  }
  
  print_r('Where are the animals?'); die; // &lt;&lt; Current result
  </code></pre>
  
  <p>Reference: <a href="http://www.doctrine-project.org/api/mongodb_odm/1.0/class-Doctrine.ODM.MongoDB.PersistentCollection.html" rel="nofollow noreferrer">Doctrine\ODM\MongoDB\PersistentCollection</a></p>