Many-to-many relationships

Hi All,

My Databse is like below :

Student table :

  • st_id

  • name

  • add1

  • phone

Sports Table :

  • spr_id

  • spr_name

  • event_date

Registration table :

  • reg_id

  • st_id

  • spr_id

In this structure, A student can participate in more than one activity. Same way a particular sport activity has more than one student.

I created a relationship in my model is like :

Student model :

‘rel_sports’ => array(self::MANY_MANY, ‘Sports’, ‘registration(st_id, spr_id)’),

Sports Model :

‘rel_student’ => array(self::MANY_MANY, ‘Student’, ‘registration(spr_id, st_id)’),

Registration model :

‘rel_student’ => array(self::BELONGS_TO, ‘Student’, array(‘st_id’=>‘st_id’)),

‘rel_sports’ => array(self::BELONGS_TO, ‘Sports’, array(‘spr_id’=>‘spr_id’)),

So My Question is,

In Student search view, I want to add a textbox for sports name searching. In that textbox, when user enters any sports activity name, Grid will display all the students who are registered for that sports.

Search textbox must be in Student–>_search.php form.

Welcome your suggestions.

Thanks in Advance!!

Please help me ASAP.

It is very urgent :(