我仍在尝试使用 Symfony2 和 Doctrine 中的连接。
到目前为止,我得到了这个:
控制器
$ownRepo = $this->getDoctrine()
->getRepository('GameShelfUsersBundle:Ownership');
$ownQuery = $ownRepo->createQueryBuilder('own')
->leftJoin('own.games','g', 'WITH', 'g.id = own.game')
->where('own.user = :user')
->andWhere('own.own = :type')
->setParameters(array(
'user' => $user,
'type' => $type
))
->orderBy('own.updated','desc')
->getQuery()
->getResult();
所有权实体(底部) - 因为它是 long - pastebin。
当我尝试运行控制器时出现错误:
QueryException: [Semantical Error] line 0, col 79 near 'g WITH g.id =': Error: Class GameShelf\UsersBundle\Entity\Ownership has no association named games
QueryException: SELECT own FROM GameShelf\UsersBundle\Entity\Ownership own LEFT JOIN own.games g WITH g.id = own.game WHERE own.user = :user AND own.own = :type ORDER BY own.updated desc
我在这里做错了什么?