0
我写一个小论坛一样的应用程序(在Symfony2中)最大的实体,我遇到了以下问题:学说2.2得到协会
我有两个实体:
class ForumThread {
public $fourmThreadId;
public $title;
public $posts; // aggregation field -> ArrayCollection of ForumPost (can't be empty)
}
class ForumPost {
public $content;
public $timeCreated;
public $thread; // aggregation field -> ForumThread (can't be null)
}
我现在想要获得所有论坛主题,包括每个主题的最新帖子。我想使用它的论坛概述:
-------------------------------------
| Thread | Last Post |
-------------------------------------
| Name of Thread #1 | ### |
| Name of Thread #2 | ### |
| ... | ... |
-------------------------------------
我想获取完整的ForumPost
实体,而不是单个字段(如时间戳)。
此外它应该是高性能的:理想情况下在1-2个查询中(我使用INNER JOIN发现了原始SQL中的某些内容,但我希望在DQL中或理想情况下使用QueryBuilder - 并且我的翻译尝试从SQL到DQL没有成功)。