db\ActiveRecord updateAllCounters()

updateAllCounters() public static method

Updates the whole table using the provided counter changes and conditions.

For example, to increment all customers' age by 1,

Customer::updateAllCounters(['age' => 1]);
public static integer updateAllCounters ( $counters, $condition = '', $params = [] )
$counters array

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

$condition string|array

The conditions that will be put in the WHERE part of the UPDATE SQL. Please refer to yii\db\Query::where() on how to specify this parameter.

$params array

The parameters (name => value) to be bound to the query. Do not name the parameters as :bp0, :bp1, etc., because they are used internally by this method.

return integer

The number of rows updated

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

Please login to continue.