Filters in doctrine

nHibernate has a great feature called filters so I can create global criteria for my applications. I am starting a PHP project and I need to use an ORM, I would like to know if Doctrine has a similar function for manipulating query conditions.

thank

+2


source to share


2 answers


Doctrine 2.2 has a filtering system that allows the developer to add SQL to conditional clauses, regardless of where the SQL is generated (for example, from a DQL query or by loading related objects).

The filter functionality works at the SQL level. Whether the SQL query is created in Persister, on lazy loading, in extra lazy collections, or from DQL. Each time the system iterates over all of the enabled filters, adding a new piece of SQL as a filter is returned.



By adding SQL to conditional query clauses, the filtering system filters out rows belonging to entities at the SQL result set level. This means that the filtered objects are never hydrated (which can be costly).

0


source


I think you are looking for Doctrine Query Hooks.

There are many hooks out there for preUpdate, preSave, preCreate, postCreate, postUpdate, postSave, preSelect, etc. etc.



Hope it helps.

-1


source







All Articles