The table group_field acts as a go-between, so the Many->Many relationship works. As such, you’re not directly given access to it. You have a few options:
[list=1]
[*]Move field_order to the "fields" table
[*]Perform another query to get the field order for each field:
[/list]
foreach($fields as $individual_field) {
$field_order = GroupField::model()->findByPk($individual_field->field_id)->field_order;
}
It’s not particularly clean, but it’s a starting point.
@georgebuckingham: I agree, gets the job done! One main concern with this approach is the performance hit for running a query for each field. Suppose I could get all the field_ids and run a "IN" query along with the group_id. Pseudo SQL - Sel field_id from group_field where group_id = n and field_id IN ( field_ids… ).
I was hoping of a straight-forward way of accessing the field_order via the matched Field Models.
@softark: when I look at that relationship, my head keeps saying “noo, that’s not right!” ha ha, no offence! But I might give it a try also…good to try out variations in my n00b state!
Hi Say_Ten, the ‘through’ functionality works like a charm! Thanks for pointing that out. I did have a look at it previously but didn’t really comprehend it fully. But had another look, at your direction and it all fell in to place.