0

I want to make

$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);

but I have this kind of error:

[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

I have followed the tutorial from symfony2 website.

ANY help please? See ya

I have no idea

JamesHalsall
  • 13,224
  • 4
  • 41
  • 66
Sam
  • 779
  • 3
  • 18
  • 39
  • In doctrine1.2, you would have done `T.Person Pe`, isn't it the same in doctrine2 ? – greg0ire Dec 01 '11 at 09:24
  • Do you mean ->createQuery(' SELECT P.* FROM MyNameSpaceProfileBundle:Tutor T JOIN T.Person Pe JOIN T.KidContent KC JOIN KC.Post P WHERE T.id = :id' )->setParameter('id', $pId); ? – Sam Dec 01 '11 at 09:30
  • I have tried: $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); But still have **error** – Sam Dec 01 '11 at 09:39
  • It cannot be the exact same error, since the error contains "MyNameSpaceProfileBundle:Person" – greg0ire Dec 01 '11 at 10:43
  • [Semantical Error] line 0, col 17 near '* ': Error: Class MyNamespace\MediaBundle\Entity\Post has no field or association named * – Sam Dec 01 '11 at 11:47
  • Ok so it's not the same error *at all* Try removing the `.*`, and please read this : http://www.doctrine-project.org/docs/orm/2.1/en/reference/dql-doctrine-query-language.html – greg0ire Dec 01 '11 at 12:48
  • Cool it works... It was just because of the "*" – Sam Dec 01 '11 at 13:59

1 Answers1

0

Trying this makes it work:

$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);
greg0ire
  • 22,714
  • 16
  • 72
  • 101