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 the COUNT(result)
for you, or use the paginator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With