我在Symfony2中新的,我不知道如何寫在Symfony2中使用的createQuery()一下面的查詢Symfony2的學說查詢
select * from Post inner join Category on Post.category_id=Category.id inner join Priority on Post.priority_id=Priority.id order by priority_number desc
我使用存儲庫類,其中,寫了一個函數
public function findAllOrderedByPriorityPost()
{
return $this->getEntityManager()
->createQuery('select p,c,pr from RodasysfourmBundle:Post p inner join
RodasysfourmBundle:Category c inner join RodasysfourmBundle:Priority pr order by pr.priorityNumber desc')
->getResult();
}
,當我用這個功能,我得到了下面的錯誤
[Semantical Error] line 0, col 85 near 'c inner join': Error: Identification Variable RodasysfourmBundle:Category used in join path expression but was not defined before.
而且其方法是使用最好的這個查詢在自定義reposito ry還是作爲服務?
任何幫助表示讚賞。