public updateCounters ( array $counters ) : boolean | ||
$counters | array | the counters to be updated (attribute name => increment value) Use negative values if you want to decrement the counters. |
Результат | boolean | whether the saving is successful |
public function updateCounters($counters)
{
if (static::updateAllCounters($counters, $this->getOldPrimaryKey(true)) > 0) {
foreach ($counters as $name => $value) {
if (!isset($this->_attributes[$name])) {
$this->_attributes[$name] = $value;
} else {
$this->_attributes[$name] += $value;
}
$this->_oldAttributes[$name] = $this->_attributes[$name];
}
return true;
} else {
return false;
}
}