嗯 - 看起來像基本問題已被回答。但你的安裝程序會讓我稍微有些迷惑......
我想我會稍微調整你的表格(假設國際化不是問題)。除此之外,我不覺得'類別'和'圖庫'的概念之間有根本的區別。現在,可能會出現「超級」和「次級」類別/畫廊,並且圖像可能一次屬於多個(即,來自Renniasance,Michaelangelo,雕塑等)。它類似於標籤的概念。
我可能會修改你的表,是這樣的:
Gallery (or Category, if you prefer)
=============
id -- autoincrement
name -- varchar(50) or something, unique
parent -- fk reference to another Gallery.id row, optional
Image
==========
id -- autoincrement
name -- varchar(50) or similar, non-unique
path -- store as URI/URL, unique
description -- varchar(128) or similar
Gallery_Image
===============
galleryId -- fk reference to Gallery.id
imageId -- fk reference to Image.id
-- the pair is unique
Related_Gallery -- optional table
================
galleryId -- fk reference to Gallery.id
relationship -- code, or fk reference to other table
relatedId -- fk reference to Gallery.id
-- entire row should be unique
-- somewhat tricky to use.
我嘗試這樣做,但這種查詢選擇最新圖庫不管畫廊有圖片或不:「選擇P檔FROM NewsAdminBundle:畫廊p其中p .category_id =:category AND p.id IN(SELECT i FROM NewsAdminBundle:GalleryImages i)ORDER BY p.created_at DESC' – repincln 2012-04-09 20:16:42