开发者

Doctrine Pager and Group By

开发者 https://www.devze.com 2023-01-26 11:01 出处:网络
I\'m having an issue with Doctrine\'s pager when the original query has a GROUP BY. The pager will generate this query:

I'm having an issue with Doctrine's pager when the original query has a GROUP BY. The pager will generate this query:

SELECT COUNT(*) AS num_results FROM event e GROUP BY e.type

which is not correct as the original query should be encapsulated in parenthesis. It should be:

SELECT COUNT(开发者_如何学C*) FROM (SELECT * AS num_results FROM event e GROUP BY e.type)

Do you have any suggestions on how to go around this?


Try this:

$table->setAttribute(Doctrine_Core::ATTR_QUERY_LIMIT, Doctrine_Core::LIMIT_ROWS);

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

0

精彩评论

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