Doctrine2 - 有预选钩吗? [英] Doctrine2 - is there a pre-selection hook?

查看:172
本文介绍了Doctrine2 - 有预选钩吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Symfony2 / Doctrine2开发一个ws,我试图钩住Doctrine2生命周期,并在任何SELECT操作之前触发一个函数,但没有任何运气。基本上,我想在请求中找到某些参数时动态地操作选择查询添加limit / offset,但是似乎 Doctrine2 hooks 仅涉及插入,删除和更新操作。我错过了什么吗?



谢谢。

解决方案

使用教义过滤器



Doctrine 2.2具有一个过滤器系统,允许开发人员将SQL添加到查询的条件子句,无论生成SQL的位置(例如,从DQL查询或通过加载关联实体)。


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.

解决方案

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

这篇关于Doctrine2 - 有预选钩吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆