我有与 manyToMany 关系的“发布”实体
/**
* @ORM\ManyToMany(targetEntity="Core\CoreBundle\Entity\User", cascade={"persist", "remove", "merge"})
* @ORM\JoinTable(name="blogregion_post_views")
*/
protected $views;
/**
* @ORM\ManyToMany(targetEntity="Application\BlogRegionBundle\Entity\PostTag", cascade={"persist", "remove", "merge"})
* @ORM\JoinTable(name="blogregion_tags_match")
*/
protected $tags;
我想获得一个新帖子
$query = $this->getEm()->createQuery("
SELECT p FROM BlogRegionBundle:Post p LEFT JOIN p.tags t LEFT JOIN p.views v
WHERE t.id = :blogId AND p.state = :state AND p.deleted = 0 AND (v <> :user OR v IS NULL )
")
->setParameter('blogId', $blogId)
->setParameter('state', 1)
->setParameter('user', $this->getUser())
;
但如果我的用户存在于“views”关系中,它会返回“Post”
我该如何解决这个问题?