|
|
|
@ -850,6 +850,15 @@ class ActiveRecord extends Model
|
|
|
|
|
$this->afterSave(false); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($this->getIndexSchema()->isRuntime) { |
|
|
|
|
$values = array_merge($values, $this->getOldPrimaryKey(true)); |
|
|
|
|
$command = static::getDb()->createCommand(); |
|
|
|
|
$command->replace(static::indexName(), $values); |
|
|
|
|
// We do not check the return value of replace because it's possible |
|
|
|
|
// that the REPLACE statement doesn't change anything and thus returns 0. |
|
|
|
|
$rows = $command->execute(); |
|
|
|
|
} else { |
|
|
|
|
$condition = $this->getOldPrimaryKey(true); |
|
|
|
|
$lock = $this->optimisticLock(); |
|
|
|
|
if ($lock !== null) { |
|
|
|
@ -865,6 +874,7 @@ class ActiveRecord extends Model
|
|
|
|
|
if ($lock !== null && !$rows) { |
|
|
|
|
throw new StaleObjectException('The object being updated is outdated.'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($values as $name => $value) { |
|
|
|
|
$this->_oldAttributes[$name] = $this->_attributes[$name]; |
|
|
|
|