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沒有成功)。