Model Relation with composite key

Hi All,

I need help in creating a model relation to a table with composite key.

Scenario:-

Table 1.

id (primary)

level

Table 2.

id (primary)

program

Table 3.

id (primary)

section

table 4.

id (primary)

user

table 5.

id (primary)

year

table 6.

id (primary)

term

Table 7.

id (primary)

levelId, (FK)

programId, (FK)

sectionId, (FK)

userId, (FK)

yearId (FK)

valid

Table 8.

userId, programId, sectionId, termId, yearId (composite key)

Grade

Now

I am calling the Table 7 model data and getting all the info, foreach user i need the grade based on the composite key in Table 8.

How can i make a relation to get the info.

Kindly help!!!!

Regards,

Wenceslaus D’silva

bump

Add this to your Model:


    	public function primaryKey()

    	{

        	return array('userId', 'programId', 'sectionId', 'termId', 'yearId');

    	}



;)

hi i have used in my relation

public function relations() {

	return array(


		


			'relation name' => array(self::MANY_MANY, 'User(relate table)', '{{table name(composite table)}}(column1, column2)'),


	);


}