0

I've this DQL request in my PageRepository :

SELECT p, b
FROM CmsCmsBundle:Page p
JOIN b.page p
WHERE p.position = :position

And this error message appear :

[Semantical Error] line 0, col 51 near '.page p WHERE': Error: Identification Variable b used in join path expression but was not defined before.

I have 2 entities (page and block) with bidirectionnal relation like this :

/**
 * (Block.php (without "s" )
 * @ORM\ManyToOne(targetEntity="Cms\CmsBundle\Entity\Page", inversedBy="blocks")
 * @ORM\JoinColumn(nullable=false)
 * @Assert\Valid()
 */
private $page;

 /**
  * (page.php)
  * @ORM\OneToMany(targetEntity="Cms\CmsBundle\Entity\Block", mappedBy="page", cascade={"persist"})
  * @ORM\JoinColumn(nullable=false)
  * @Assert\Valid()
  */
 protected $blocks;

Some idea ?

Problem solved, I've just inversed "b.page p" instead of "p.blocks b"

Kev
  • 171
  • 2
  • 19
  • Your query syntax doesn't look right. See if this helps: http://stackoverflow.com/questions/11116428/symfony-2-inner-join-on-non-related-table-with-doctrine-query-builder – Maximus2012 Jul 30 '13 at 15:35
  • Strange, I've use this syntaxe in an older project and it's work... This project use SF 2.3 and the other 2.1, do you think this because of that ? In your link they use createQueryBuilder() and me juste createQuery() but I'll try. – Kev Jul 30 '13 at 15:46
  • I've found the problem ! I'll add in my post, thank for you help Maximus2012 – Kev Jul 30 '13 at 15:50

0 Answers0