Smart Relations

Hey guys, a while ago I was rather quick about getting my ranking system done with average rankings. This system uses relations to get the average ranking with a condition. It looks like this:


public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'overallAVG1' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=1',),

			'overallAVG2' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=2',),

			'overallAVG3' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=3',),

			'overallAVG4' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=4',),

			'overallAVG5' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=5',),

			'overallAVG6' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=6',),

			'overallAVG7' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=7',),

			'overallAVG8' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=8',),

			'overallAVG9' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=9',),

			'overallAVG10' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=10',),

			'overallAVG11' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=11',),

			'overallAVG12' => array(self::STAT, 'Ranking', 'game_id', 'select' => 'AVG(overall)', 'condition'=>'platform_id=12',),

		);

	}



I was wondering if there is a better method to achieve this? I am planning to do the same with two or three more columns of the table, and that will make it kind of a long list of relations :)

Perhaps by writing the condition in the view files when i’m retrieving it instead? If that is possible, how to do it then?

anyone?