Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return collections of models as an iterable class rather than an array #179

Closed
peter-fritchley opened this issue Jul 25, 2012 · 5 comments
Closed

Comments

@peter-fritchley
Copy link

This would allow passing around a query, which would get executed at the point at which someone tries to iterate it. This approach would give greater flexibility - since at each level of processing, further conditions / relations could be added. It would also remove the need for \Orm\Query::get().

@WanWizard
Copy link
Member

I understand (and like) the idea.

But it would not remove the get(), as that is actually the SQL execution trigger which would create the iterable class. You will have to create and populate it before you can access it's data.

@peter-fritchley
Copy link
Author

I thought that the class could keep track of whether the internal store of models had been generated, and trigger the SQL on the first iteration (or the first iteration after new conditions have been added). Then you don't need to care about whether the data has been fetched yet or not.

@WanWizard
Copy link
Member

Ok, but you would still need the get() for all other scenario's (in which you want to access the object without iteration).

@AddoSolutions
Copy link

I have posted a solution to this here:

See my original thread here: #249

and the pull request #270

@WanWizard
Copy link
Member

Continue the discussion in that thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants