素材牛VIP会员
yii2的数据操作
 th***as  分类:ThinkPHP  人气:922  回帖:1  发布于6年前 收藏

请问各位YII2中有没有一个方法是跟TP框架里的setInc和setDec相同的功能

 标签:yiithinkphpphp

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv7 码师
15***by 产品经理 6年前#1
/**
  • 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()
    */

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取