Yii Framework Forum: Two Right Joins In A Relationship - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Two Right Joins In A Relationship Rate Topic: -----

#1 User is offline   crasx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 29-October 11

Posted 19 January 2013 - 03:26 PM

Hi

I am working on some review/rating software and have the table relationships set up as such:

Ratings->Review->Item


So, an item has multiple reviews from people, and each review has multiple ratings associated with it. How do I add a relationship to get the average rating for an item?

Ratings fk is 'review' referencing Review's pk.
Review's fk is 'item' referencing Item's pk

Here is what I am playing with in the Item Model

'Ratings'=>array(self::MANY_MANY, 'ReviewReviewRatings',  '3d_review_reviews(review, item)',),
'AverageRating'=>array(self::STAT, 'Ratings', 'reviews(review, item)', 'select'=>'avg("t"."value")'),


but this wouldn't work because The PK for Ratings it not what is mentioned in Reviews, so is there any way to do this or do I need to do it some other way?

Thanks
m.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users