Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Sorting within a many_many-relation


Go to End


2 Posts   3093 Views

Avatar
Steven

Community Member, 6 Posts

6 February 2008 at 4:49am

Hi there,

I probably have got a really novice question, but I wasn't able to find anything about that:

How can I sort the output of a n:n-relation? I my specific case I've got a catalog, including categories and products. Each product can be assigned to multiple categories.

It is no problem to sort a 1:n-relation via DataObject::get(...). But using the n:n-relation, there is one more table to manage and I don't know, how to include it into my query.

Steven

Avatar
Steven

Community Member, 6 Posts

6 February 2008 at 11:12pm

ok, I fixed it by redeclaring the JOIN-Term.
I was trying to (re)use that JOIN, silverstripe is extracting out of the relation-definition.

Steven