Skip to content

Instantly share code, notes, and snippets.

@steppefox
Created November 4, 2013 08:08
Show Gist options
  • Save steppefox/7299541 to your computer and use it in GitHub Desktop.
Save steppefox/7299541 to your computer and use it in GitHub Desktop.
Yii relations managment (with new throught option)
public function relations()
{
return array(
'roles'=>array(self::HAS_MANY,'Role','group_id'),
'users'=>array(self::HAS_MANY,'User',array('user_id'=>'id'),'through'=>'roles'),
'comments'=>array(self::HAS_MANY,'Comment',array('id'=>'user_id'),'through'=>'users'),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment