php - yii2的数据操作
本文介绍了php - yii2的数据操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
请问各位YII2中有没有一个方法是跟TP框架里的setInc和setDec相同的功能
解决方案
/**
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()
*/
这篇关于php - yii2的数据操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文