Doctrine 2 DQL - how to select inverse side of unidirectional many-to-many query?

前端 未结 5 1144
南笙
南笙 2020-12-23 21:53

I have two classes - Page and SiteVersion, which have a many to many relationship. Only SiteVersion is aware of the relationship (because the site is modular and I want to b

5条回答
  •  庸人自扰
    2020-12-23 22:19

    I think you need to select the SiteVersion in your query too:

    SELECT v, p FROM SiteVersion v JOIN v.pages p WHERE v.id = 5 AND p.slug='index'
    

    You will get an array of SiteVersion entities which you can loop through to get the Page entities.

提交回复
热议问题