I’m building a photo gallery. I have a many to many relationship between the art and the galleries tables. Each gallery can have the art in them sorted (weighted) in their own way. I may be committing some kind of sin but it seems logical to store the weight of each art record in the join table. So now I have this in my model (does the art sorting within the gallery):
'artWeight'=>array(self::HAS_MANY, 'galXart', 'galID'), 'art'=>array(self::MANY_MANY, 'art', 'galXart(galID, artID)', 'with'=>'artWeight', 'order'=>'artWeight.weight ASC'),
This works fine for sorting the art in each gallery. However I’m having a hard time getting the actual value of the join table’s weight field printed in my page.
I gather the art from the galleries relationship this way:
$art = $model->art; $this->renderPartial('_thumbs',array( 'gallery' => $model, 'art' => $art, ));
This may seem foolish to you pros, but I can’t figure out how to access the weight field buried in the $art object.