If you have a composite primary key in your emap table, one suggestion is to take advantage of YII’s MANY_MANY relationship. Your Consulation relations array could have an entry that looks like this
'sickEntries' => array(self::MANY_MANY, 'Sickness', 'emap(fk_cons, fk_sick)'), // Assuming emap is the name of your table
Then all you would need to do is
$consultation = Consultation::model()->find($criteria);
foreach ($consultation->sickEntries as $sickEntry)
{
// $sickEntry should be an instance of the Sickness class
}
You condition is all wrong: What attribute are you comparing $keyword to?
Look in a model actionSearch() function. the group of compares() show how to do this. The 3rd param, I believe, is for partial matches. That means ‘LIKE % %’.
It also looks like you are really setting up a MANY_MANY relation between Consultation and Sickness THROUGH Emap. Just thinking.
tnx for reply sir, lets disregard that criteria I made. what i really wanted to do is there is one consultation process and i would like to get access or get those selected sickness word used in consultation using the relation of consultation->emap->sickness do you have any idea or sample codes for HAS_MANY relations
lets forget that keyword, well my real concern is i want to display the sck_word in my consultation cgridview and filter it. tnx please help me with this.
I think ‘sickness’ above should be a self::MANY_MANY relation. The rest of the options don’t look exactly right but I don’t have the info at my fingertips