Browse Source

Fixes #637.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
a4239efa7c
  1. 3
      framework/yii/db/ActiveRecord.php

3
framework/yii/db/ActiveRecord.php

@ -1256,6 +1256,9 @@ class ActiveRecord extends Model
$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;

Loading…
Cancel
Save