Skip to content

Commit

Permalink
Fixes yiisoft#637.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Jul 18, 2013
1 parent b28e6b9 commit a4239ef
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions framework/yii/db/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,9 @@ public function link($name, $model, $extraColumns = array())
$relation = $this->getRelation($name);

if ($relation->via !== null) {
if ($this->getIsNewRecord() || $model->getIsNewRecord()) {
throw new InvalidCallException('Unable to link models: both models must NOT be newly created.');
}
if (is_array($relation->via)) {
/** @var $viaRelation ActiveRelation */
list($viaName, $viaRelation) = $relation->via;
Expand Down

0 comments on commit a4239ef

Please sign in to comment.