Open doctrinebot opened 10 years ago
Comment created by mnapoli:
Added option 3 after trying to write a POC
Comment created by mnapoli:
Here is a POC on the doctrine/collections side: https://github.com/mnapoli/collections/compare/master...feature;Updatable works with ArrayCollection
I'm looking at the ORM side.
Feedback welcome, especially with the class/namespace/method names.
Jira issue originally created by user mnapoli:
I created a discussion in the mailing list (https://groups.google.com/forum/#!topic/doctrine-dev/7HfEqOwhkDk) but no answer, so I'm moving the discussion here.
The Criteria API provides an abstraction to filter collections/repositories, may they be in memory (filtering in PHP) or in a database (filtering using a SQL query).
I was thinking about an "Expression" API which would work like array_map to apply changes in bulk to entities.
For example, if you have a collection where entities have a $position field, if I insert an item in the list, I have to increment the position of all the following items. For this, I have 2 options:
The second option is much more efficient, but it breaks the abstraction of the model because I have some behavior written explicitely in SQL. Furthermore, the objects loaded in memory will note be updated with the SQL query.
So the "Expression" API would work like the Criteria API:
The expression here would be applied:
The expression could be applied to a Collection and to a Repository (like the Criteria).
About the API offered by the Expression class, there are several options:
I think I like the third one better because we have full control over the supported operations, and adding support to new kinds of operation is easy. The first one would require defining a whole language of allowed expressions...
What do you think of all that?