Doctrine2 - is there a pre-selection hook?

2019-08-05 16:45发布

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.

2条回答
闹够了就滚
2楼-- · 2019-08-05 17:18

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.

查看更多
霸刀☆藐视天下
3楼-- · 2019-08-05 17:33

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).

查看更多
登录 后发表回答