Commit 25f919c1 by Carsten Brandt

Merge pull request #3711 from savvot/master

yii\redis\ActiveRecord::deleteAll() refactoring
parents 13c10df4 5655a5fc
......@@ -233,20 +233,19 @@ class ActiveRecord extends BaseActiveRecord
*/
public static function deleteAll($condition = null)
{
$pks = self::fetchPks($condition);
if (empty($pks)) {
return 0;
}
$db = static::getDb();
$attributeKeys = [];
$pks = self::fetchPks($condition);
$db->executeCommand('MULTI');
foreach ($pks as $pk) {
$pk = static::buildKey($pk);
$db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]);
$attributeKeys[] = static::keyPrefix() . ':a:' . $pk;
}
if (empty($attributeKeys)) {
$db->executeCommand('EXEC');
return 0;
}
$db->executeCommand('DEL', $attributeKeys);
$result = $db->executeCommand('EXEC');
......
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