Doctrine2 - is there a pre-selection hook?

半世苍凉 提交于 2019-12-11 13:49:25

问题


I'm developing a ws with Symfony2 / Doctrine2, and I'm trying to hook into Doctrine2 lifecycle and trigger a function before any SELECT action - but without any luck. Basically, i'd like to dynamically manipulate the selection queries adding limit/offset when certain parameters are found in the request, but it seems that Doctrine2 hooks concern only insert, delete and update actions. Am i missing something?

Thanks.


回答1:


U have to use Doctrine Filter

Doctrine 2.2 features a filter system that allows the developer to add SQL to the conditional clauses of queries, regardless the place where the SQL is generated (e.g. from a DQL query, or by loading associated entities).




回答2:


A way to deal with this would be to register a custom event that is dispatched before a select. You have already referenced the source that shows examples of how to do it.



来源:https://stackoverflow.com/questions/14943619/doctrine2-is-there-a-pre-selection-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!