thinkphp中setInc、setDec方法

可用于统计字段(通常是数字类型的字段)的更新,例如积分,等级,登陆次数等

必须配合连贯操作where一起使用

$User = M("User"); // 实例化User对象
$User->where('id=5')->setInc('score',3); // 用户的积分加3
$User->where('id=5')->setInc('score'); // 用户的积分加1
$User->where('id=5')->setDec('score',5); // 用户的积分减5
$User->where('id=5')->setDec('score'); // 用户的积分减1
Db::name("hmenu")->where("id",$lm_id["mid"])->setInc("ar_cont");

 

相关文章:

  • 2021-09-12
  • 2021-05-30
  • 2021-08-20
  • 2021-10-07
  • 2021-09-05
  • 2021-09-06
猜你喜欢
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-12-05
相关资源
相似解决方案