exp wrote:Elberet, your random thoughts would mean 300+ sql queries for some of the animes on anidb if the user clicks on expand all link.
Hmmm... no.
One query joining files, episodes and languages can give you all languages for all files for all episodes of an anime. Just "order by episode.number asc, files.size desc, files.id asc". Then, load the first returned row. If the next row has the same file id, take it's language information and ignore the rest. If the file id differs, output the current file and continue to the next. The ordering in the SQL statement should make sure that nothing bad happens, even if two files have the exact same size (or whatever sorting criterium the user has selected).
For example, the DB query would return
Code: Select all
files.id | ... | lang.type | lang.short
----------+-----+-----------+------------
123 | | dub | jap
123 | | dub | eng
123 | | sub | eng
456 | | dub | ger
789 | | dub | jap
789 | | dub | eng
789 | | dub | ger
789 | | sub | eng
789 | | sub | ger
Instead of or additionally to lang.short, you can store the URL to an icon image, alt="" tag or label, a flag whether to use the icon image or a text tag, etc.
The query will use more memory, but shouldn't decrease performance noteably since the new languages table is not very complex and all columns involved in the join are unique indices.