Commit 7e0c6353 by Carsten Brandt

optimized redis AR insert

parent ece300ac
......@@ -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);
......
......@@ -4,6 +4,7 @@ Yii Framework 2 redis extension Change Log
2.0.0-rc under development
--------------------------
- Bug #1311: Fixed storage and finding of `null` and boolean values (samdark, cebe)
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment