|
|
|
@ -120,16 +120,14 @@ class ActiveRecord extends BaseActiveRecord
|
|
|
|
|
$key = static::keyPrefix() . ':a:' . static::buildKey($pk); |
|
|
|
|
// save attributes |
|
|
|
|
$setArgs = [$key]; |
|
|
|
|
$delArgs = [$key]; |
|
|
|
|
foreach ($values as $attribute => $value) { |
|
|
|
|
// only insert attributes that are not null |
|
|
|
|
if ($value !== null) { |
|
|
|
|
if (is_bool($value)) { |
|
|
|
|
$value = (int)$value; |
|
|
|
|
} |
|
|
|
|
$setArgs[] = $attribute; |
|
|
|
|
$setArgs[] = $value; |
|
|
|
|
} else { |
|
|
|
|
$delArgs[] = $attribute; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -137,10 +135,6 @@ class ActiveRecord extends BaseActiveRecord
|
|
|
|
|
$db->executeCommand('HMSET', $setArgs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (count($delArgs) > 1) { |
|
|
|
|
$db->executeCommand('HDEL', $delArgs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$changedAttributes = array_fill_keys(array_keys($values), null); |
|
|
|
|
$this->setOldAttributes($values); |
|
|
|
|
$this->afterSave(true, $changedAttributes); |
|
|
|
|