Doctrine 1.2,在多对多表上运行查询
我想在 Doctrine 1.2 下自动生成的表上进行查询。在这种特殊情况下,我有以下查询:
SELECT F.id FROM ficha as F JOIN ficha_has_tema FT ON FT.ficha_id = F.id WHERE FT.tema_id = ? GROUP BY F.id HAVING COUNT(F.id) > 1
但我收到错误:
未捕获的异常“Doctrine_Exception”,消息为“找不到” ficha_has_tema' 类位于...
那么,有没有一种方法可以使用学说进行此查询而不创建类 ficha_has_tema?我需要进行计数。
谢谢!
I want to make a query on an automatic generated table under Doctrine 1.2. In this particular case I have the following query:
SELECT F.id FROM ficha as F JOIN ficha_has_tema FT ON FT.ficha_id = F.id WHERE FT.tema_id = ? GROUP BY F.id HAVING COUNT(F.id) > 1
But I get the error:
Uncaught exception 'Doctrine_Exception' with message 'Couldn't find
class ficha_has_tema' in...
So, is there a way to make this query using doctrine without creating the class ficha_has_tema? I need to do the COUNT.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在此处执行 DQL 查询。不可能使用在 SQL 查询中没有关联实体的表。
运行旧式 SQL
但是,您可以按照“将原始 SQL 与 Doctrine 结合使用”
或者 Doctrine Native SQL Support 之类的东西(从未亲自尝试过,可能需要一些修改)
I assume you are executing DQL query here. It's impossible to use tables that have no associated entities wihthin the SQL queries.
However, you may run good-old SQL with
as suggested in "Using Raw SQL with Doctrine"
Or Doctrine Native SQL Support with something like (never tried that personally, might require some modification)