I have an interesting problem that I am not sure how to approach so I
thought I’d ask for some advice.
I have an a shopping cart application that uses HABTM table joins. I
have a table for products (music) and one for artists associated with
the products. Any product can have one or more artists associated with
it. I then create a product listing of the whole catalog like so
Artist Name 1 / Artist Name 2 / etc - Product Title CD
Benumb / Pig Destroyer - Split CD
Converge / Agoraphobic Nosebleed - The Poacher Diaries CD
Aborted - MadeUpName CD
Ben’s Band / Jerry’s Band / My Band / Your Band - Rubbish CD
The problem is, I’d to sort the list alphabetically at this point, and
also take account of the fact that I would like to paginate it all. The
only way I can think of doing it is reading out the whole database,
formatting the full product name as I want, pushing them formatted into
an array, sorting them and then limiting how many items I want to view.
To be honest most of the products will only have one artist and a few
exceptions won’t its just I wanted to be clever and now its coming back
to haunt me. Am I over complicating things?
Any advice would be appreciated.