mongodb\ActiveRecord updateAllCounters()

updateAllCounters() public static method

Updates all documents in the collection 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 = [], $options = [] )
$counters array

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

$condition array

Description of the objects to update. Please refer to yii\mongodb\Query::where() on how to specify this parameter.

$options array

List of options in format: optionName => optionValue.

return integer

The number of documents updated.

doc_Yii
2016-10-30 17:07:29
Comments
Leave a Comment

Please login to continue.