[TYPO3-mvc] Using mm-table for sorting in query

Franz Koch typo3.RemoveForMessage at elements-net.de
Mon Feb 28 12:45:18 CET 2011


Hey,

> I have kind of problem with sortings. My table structure looks like this:
>
> gallery <-- gallery_album_mm --> album
>
> Inside the gallery_album_mm table, I have a field 'sorting' that is used
> for sorting albums in a gallery.
>
> Now I want to create a query that allows me to get the albums in the
> right sorting for a gallery WITHOUT USING THE GALLERY object like
> $gallery->getAlbums(). For the reasons see below.
>
> Does anybody have an idea how I can do that. Normally I would use kind
> of a JOIN statement and order the albums due to the joined field 'sorting':
>
> SELECT * FROM album
> JOIN gallery_album_mm mm ON mm.foreign_uid = album.uid
> ORDER BY mm.foreign_sorting
>
> But there is no join in repository queries... so what can I do?

I fear your albums need a backreference to the gallery. After having 
that it shouldn't be a big deal. Is it possible for you to add 
backreferences to the albums?

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list