I have many, many relationships in my project (user_role, grades, user_role_grades). But I also have a requirement not to delete data from my db. Thus, I add a status column to a table that joins 2 tables to create many, many relationships. Now i want on
$userRole->getGrades()
get only those records that in the join table (user_role_grades) do not have the status "0". For those, I'm trying to use doctrine sql filter.
namespace Bis\MpBundle\Filter; use \Doctrine\ORM\Mapping\ClassMetaData; class UserRoleGradeFilter extends \Doctrine\ORM\Query\Filter\SQLFilter { public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) { if("Bis\DefaultBundle\Entity\UserRoleGrade" == $targetEntity->name){ return $targetTableAlias . '.status != 0'; } return ''; } }
So, it is called for Bis \ DefaultBundle \ Entity \ UserRole, but not for the Bis \ DefaultBundle \ Entity \ UserRoleGrade object. Does anyone have any ideas?
Or maybe you have other ideas, how can I do this?
source share