Doctrine orm 原则:获得用户的帖子

Doctrine orm 原则:获得用户的帖子,doctrine-orm,doctrine,many-to-many,dql,Doctrine Orm,Doctrine,Many To Many,Dql,如何从用户跟踪的用户检索所有帖子,类似于社交媒体上的家庭订阅源 这在SQL中非常简单,但在DQL中是什么样子的呢 从post中选择* 在朋友\用户\ id=post.from\ id上加入朋友 其中user_id=:uid 我尝试了很多类似的方法,但都没有成功: $this->getEntityManager ->createQuery '选择p 来自MyBundle:postp 加入MyBundle:u.myFriends中的用户u和p.from 其中u.id=:uid' 我的用户实体: 一种

如何从用户跟踪的用户检索所有帖子,类似于社交媒体上的家庭订阅源

这在SQL中非常简单,但在DQL中是什么样子的呢

从post中选择* 在朋友\用户\ id=post.from\ id上加入朋友 其中user_id=:uid 我尝试了很多类似的方法,但都没有成功:

$this->getEntityManager ->createQuery '选择p 来自MyBundle:postp 加入MyBundle:u.myFriends中的用户u和p.from 其中u.id=:uid' 我的用户实体:


一种简单的DQL工作方法如下所示:

$dql=从MyBundle中选择p:Post p p.从哪里来 从MyBundle中选择u:User u加入u.friendsWithMe f,其中f=:User; $query=$em->createQuery$dql; $query->setParameter':用户',$this->getUser;
希望此帮助

一个简单的DQL工作方法如下:

$dql=从MyBundle中选择p:Post p p.从哪里来 从MyBundle中选择u:User u加入u.friendsWithMe f,其中f=:User; $query=$em->createQuery$dql; $query->setParameter':用户',$this->getUser; 希望这有帮助