db\BaseActiveRecord updateCounters()

updateCounters() public method

Updates one or several counter columns for the current AR object.

Note that this method differs from updateAllCounters() in that it only saves counters for the current AR object.

An example usage is as follows:

$post = Post::findOne($id);
$post->updateCounters(['view_count' => 1]);

See also updateAllCounters().

public boolean updateCounters ( $counters )
$counters array

The counters to be updated (attribute name => increment value) Use negative values if you want to decrement the counters.

return boolean

Whether the saving is successful

doc_Yii
2016-10-30 16:56:58
Comments
Leave a Comment

Please login to continue.