src/ActiveRecord.php
public static function updateAllCounters($counters, $condition = null)
    {
        if (empty($counters)) {
            return 0;
        }
        $db = static::getDb();
        $n = 0;
        foreach (self::fetchPks($condition) as $pk) {
            $key = static::keyPrefix() . ':a:' . static::buildKey($pk);
            foreach ($counters as $attribute => $value) {
                $db->executeCommand('HINCRBY', [$key, $attribute, $value]);
            }
            $n++;
        }

        return $n;
    }
public static function updateAllCounters($counters, $condition = null)
    {
        if (empty($counters)) {
            return 0;
        }
        $db = static::getDb();
        $n = 0;
        foreach (self::fetchPks($condition) as $pk) {
            $key = static::keyPrefix() . ':a:' . static::buildKey($pk);
            foreach ($counters as $attribute => $value) {
                $db->executeCommand('HINCRBY', [$key, $attribute, $value]);
            }
            $n++;
        }

        return $n;
    }
Updates the whole table using the provided counter changes and conditions.
For example, to increment all customers' age by 1,

~~~
Customer::updateAllCounters(['age' => 1]);
~~~

@param array $counters the counters to be updated (attribute name => increment value).
Use negative values if you want to decrement the counters.
@param array $condition the conditions that will be put in the WHERE part of the UPDATE SQL.
Please refer to [[ActiveQuery::where()]] on how to specify this parameter.
@return int the number of rows updated