开发者

Can Doctrine2 load calculated values?

Is there a way to load calculated values i开发者_StackOverflownto an entity using Doctrine2? For example, if a question has votes (the votes table having a foreign key from the question table), using SQL you could select the question and calculate a vote total.

Is something like that possible with Doctrine2?


It works the following way:

SELECT q, count(v.id) FROM Question q JOIN q.votes WHERE <condition> GROUP BY q.id

Another approach would be using an aggregate column like described here:

http://www.doctrine-project.org/projects/orm/2.0/docs/cookbook/aggregate-fields/en#aggregate-fields

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜