>  기사  >  백엔드 개발  >  yii2的数据操作

yii2的数据操作

WBOY
WBOY원래의
2016-06-06 20:16:10917검색

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

回复内容:

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

<code>/**</code>
  • 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()
    */

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.