Skip to content

Instantly share code, notes, and snippets.

@pronskiy
Created September 5, 2012 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pronskiy/3635771 to your computer and use it in GitHub Desktop.
Save pronskiy/3635771 to your computer and use it in GitHub Desktop.
Yii CActiveRecord dynamic relation adding
$class = CActiveRecord::HAS_MANY; // Или любой другой вид отношений (HAS_ONE, BELONGS_TO, MANY_MANY)
$model->getMetaData()->relations[$relationName] =
new $class(
$relationName,
$className,
$foreignKey,
$options
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment