Doctrine 查询语言中的左连接
如果我没有在谷歌上做足够的研究,我想道歉,但说实话,我不知道到底要搜索什么。我的问题是教义。我使用 Symfony 框架,我想在 DQL 中编写以下原始查询:
SELECT c.id AS id,
c.name AS name,
c.active AS active,
count(c2.id) AS depth,
(c.rht - c.lft) as rng
FROM (categories c
LEFT JOIN categories c2 ON ( (c2.lft < c.lft) AND (c2.rht > c.rht) AND c2.active ) )
GROUP by c.id
ORDER by c.lft ASC
我可以像原始查询一样编写它,但我需要在 DQL 中使用它,因为我想将它用于 sfWidgetFormDoctrineChoice 小部件。非常感谢任何帮助。
提前致谢!
I want to apologies if I haven't done enough research in google but to be honest I don't know exactly what to search for. My problem is with Doctrine. I use Symfony framework and I want to write the following raw query in DQL:
SELECT c.id AS id,
c.name AS name,
c.active AS active,
count(c2.id) AS depth,
(c.rht - c.lft) as rng
FROM (categories c
LEFT JOIN categories c2 ON ( (c2.lft < c.lft) AND (c2.rht > c.rht) AND c2.active ) )
GROUP by c.id
ORDER by c.lft ASC
I can write it like a raw query, but I need it in DQL as I want to use it for a sfWidgetFormDoctrineChoice widget. Any help is highly appreciated.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种可能的方法是:
但我认为你的方式是错误的。你检查过教义树的行为吗? http://www.doctrine-project.org/documentation/manual/1_0/nl/hierarchical-data#nested-set:advanced-usage:fetching-a-tree-with-relations
A possible approuch would be:
But I think your on the wrong way. Did you check out the tree behavior of doctrine? http://www.doctrine-project.org/documentation/manual/1_0/nl/hierarchical-data#nested-set:advanced-usage:fetching-a-tree-with-relations