我有一个数据库已经在使用,我无法真正改变它。 在这个数据库中,我使用“软删除”:而不是实际删除记录,我只修改一个标志(例如设置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
更多推荐
发布评论