mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-772: Query::iterate() returns arrays (like mixed results) #952
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Aug 27, 2010).
Jira issue originally created by user arnaud-lb:
Instead of returning queried objects, Query::iterate returns arrays with the queried objects as single elements, like mixed results :
@doctrinebot commented on GitHub (Aug 27, 2010):
Comment created by @beberlei:
This is documented behaviour, not a bug
http://www.doctrine-project.org/projects/orm/2.0/docs/reference/batch-processing/batch-processing#iterating-large-results-for-data-processing
@doctrinebot commented on GitHub (Aug 27, 2010):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Aug 27, 2010):
Comment created by arnaud-lb:
I originally checked the ::iterate() method documentation, but did not found anything about that.
Thanks!
@amorel-ljsl commented on GitHub (Apr 25, 2016):
Hi,
This is indeed documented (here now: Iterating Large Results for Data-Processing )
But is there any valid reason for that behaviour? I mean, it's a non-sense, as there can be only one result when iterating, and everyone would expect the foreach loop to produce the objects, not an array with one object.
What am i missing?
In my case, that prevented me to use an export bundle, which expects an iterator to produce CSV, because it's not made to dig one level deep into the results it gather from the iterator...
Suggestion: add a
iterateSimple()method which does what is expected.@garex commented on GitHub (Sep 30, 2016):
@amorel-ljsl workaround of this nasty behaviour is PHP7 yield.
@amorel-ljsl commented on GitHub (Sep 30, 2016):
Great tip @garex , thank you!
@enumag commented on GitHub (Dec 14, 2017):
@Ocramius Can we do something about this? Like another method that would work as expected? (See this comment)
@Majkl578 commented on GitHub (Dec 14, 2017):
Not in 2.x but feel free to propose/submit improvement for 3.0.
@SparkDragon commented on GitHub (Apr 12, 2018):
For those who can't use PHP "yield" (wich is available from PHP 5.5), you still can create a decorator :
Then you can do something like :
@Ocramius commented on GitHub (Apr 12, 2018):
Please do upgrade to a newer PHP version: older releases are no longer production-ready and should be considered a business and security risk.