2011-12-01 21 views
0

我要讓Symfony2的 - 和實體之間的語義錯誤關聯檢索信息

$this->getEntityManager() 
->createQuery(' SELECT P.* 
      FROM MyNameSpaceProfileBundle:Tutor T 
       JOIN MyNameSpaceProfileBundle:Person Pe 
       JOIN MyNameSpaceMediaBundle:KidContent KC 
       JOIN MyNameSpaceMediaBundle:Post P 
       WHERE T.id = :id' 
)->setParameter('id', $pId); 

但我有這樣那樣的錯誤:

[Semantical Error] line 0, col 128 near 'Pe ': Error: Identification Variable MyNameSpaceProfileBundle:Person used in join path expression but was not defined before. 500 Internal Server Error - QueryException

我遵循了Symfony2的網站上的教程。

請幫忙嗎? 再見

我不知道

+0

在doctrine1.2,你會做'T.Person Pe',是不是在同一個教條2? – greg0ire

+0

你的意思 - >的createQuery( 'SELECT * P.從 MyNameSpaceProfileBundle:教師牛逼 JOIN T.Person Pe的 JOIN T.KidContent KC JOIN KC.Post P WHERE T.id =:ID' ) - > setParameter('id',$ pId); ? – Sam

+0

是的,我的意思是。 – greg0ire

回答

0

嘗試這使得它的工作:

$this->getEntityManager() ->createQuery(
    'SELECT P 
    FROM '.$this->_entityName.' P 
    JOIN P.details KC 
    JOIN KC.creator T 
    JOIN T.information Pe 
    WHERE Pe.id = :id')->setParameter('id', $pId); 
+0

感謝它現在的作品 – Sam