84669 人学习
152542 人学习
20005 人学习
5487 人学习
7821 人学习
359900 人学习
3350 人学习
180660 人学习
48569 人学习
18603 人学习
40936 人学习
1549 人学习
1183 人学习
32909 人学习
请问各位YII2中有没有一个方法是跟TP框架里的setInc和setDec相同的功能
ringa_lee
/**
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]);
@param array $counters 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
@see updateAllCounters()*/
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]);
@param array $counters 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
@see updateAllCounters()
*/