自动过滤掉不符合Doctrine条件的行(Automatically filter out rows that don't meet a condition in Doctrine)

编程入门 行业动态 更新时间:2024-10-27 11:27:26
自动过滤掉不符合Doctrine条件的行(Automatically filter out rows that don't meet a condition in Doctrine)

我有一个数据库已经在使用,我无法真正改变它。 在这个数据库中,我使用“软删除”:而不是实际删除记录,我只修改一个标志(例如设置del=1 )。

我不使用GEDMO模板(SoftDelete),但我想要相同的功能。 目前,当我使用QueryBuilder / find函数时,它们返回del=1记录。 关联实体的功能相同; 如果del=0我每次都要检查。

有没有办法自动过滤掉标志为del=1记录,除非明确要求?

I have a database already in use and I can't really change it. On this database I use a "soft delete": instead of actually deleting a record, I just modify a flag (e.g. setting del=1).

I don't use the GEDMO template (SoftDelete) but I want the same functionality. Currently when I use QueryBuilder/find functions, they return records with del=1. Same idea on association entities' functions; I have to check every time if del=0.

Is there a way to automatically filter out records with flag del=1, unless it's explicitly requested?

最满意答案

你可能可以使用doctrine过滤器:

http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html http://www.michaelperrin.fr/2014/07/25/doctrine-filters/

禁用:

http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#disabling-enabling-filters-and-setting-parameters

you probably can use doctrine filters:

http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html http://www.michaelperrin.fr/2014/07/25/doctrine-filters/

to disable:

http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#disabling-enabling-filters-and-setting-parameters

更多推荐

本文发布于:2023-07-24 20:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1251040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不符合   过滤掉   条件   Doctrine   Automatically

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!