Having a QueryBuilder Result
$query = $em->createQuery("SELECT....");
Fetching them by the iterate() method
http://doctrine-orm.readthedocs.org/en/2.0.x/reference/batch-processing.html
$objects = $query->iterate();
I am now able to
foreach ($objects as $object) {
$object = $object[0];
//do something..
$object->getObjectId();
...
}
BUT…
//after the iterate() call, before to foreach
echo sizeof($objects); //or count($objects);
//always "1", even if i have 10000 foreach loops
Why and how to fix?
$query->iterate()will only give you an iterator that is not countable. Consider writing a second query that does theCOUNT(result)for you, or use the paginator