thinkphp字段加减
2022-07-28 14:14:58
130
{{single.collect_count}}

thinkphp字段加减

加操作

//单一操作一个字段
M()->where()->setInc(‘这里写要操作的字段’);//字段自动+1

M()->where()->setInc(‘要操作的字段’,2);//第二个参数是要自动增加多少
//操作多个字段
有两种写法
第一种:
$cModel = M(‘要操作的数据库’);
$cModel->id = ‘’;
$cModel->要操作的字段 = array(‘exp’,‘要操作的字段+’.‘数值’);
$cModel->save();
第二种:
$cModel = M();
$arrData = array(
‘要操作的字段’=>array(‘exp’,‘要操作的字段+’.‘数值’),
‘要操作的字段’=>array(‘exp’,‘要操作的字段+’.‘数值’),
);
cModel−>where ( ′条 件 ′)−>save(cModel->where('条件')->save( cModel>where()>save(arrData);

减操作

参考上面加操作!是一样的

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}