Building on the relations example above… once you have relations setup you can do something like this:
$group = Group::model()->find(); //get one record using one of the find() methods
$groups = Group::model()->findAll(): //get all groups matching criteria you pass to findAll()
foreach $groups as $group
foreach $group->member AS $member
I took a look at your code. Why have memberId in the group table? Wouldn’t you rather have groupId in the member table?
If you have a situation where one group HAS MANY members your tables should look like this: