开发者

How to do a subquery in doctrine and get the result hydrated to an object?

I want to do a somewhat complex query in doctrine, namely an inner join with a subquery with a group_concat.

See the query in plain SQL:

SELECT *
FROM kinderen k
INNER JOIN
(
  SELECT i.kindid, GROUP_CONCAT(开发者_StackOverflow社区DISTINCT a.periode) as periodes
  FROM inschrijvingen i
  INNER JOIN activiteiten a ON i.activiteitid=a.id
  GROUP BY i.kindid
) p
ON k.kindid=p.kindid;

1) How can I do this in doctrine? In other words how can I translate this regular sql into dql?

2) I would like the extra property (periodes) to be accessible in the resulting Kinderen object. I suspect that this is default behavior for doctrine?

I can't find the solution when I read through the docs and google.

Thanx!


Seems this is available in Doctrine 2 as a "fetch join" but not sure if it exists for 1.2.

http://www.doctrine-project.org/projects/orm/2.0/docs/reference/dql-doctrine-query-language/en

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜