thinkPHP5.0中的setInc,setDec方法


---恢復內容開始---

thinkphp中setInc、setDec方法

可用於統計字段(通常是數字類型的字段)的更新,例如積分,等級,登陸次數等

必須配合連貫操作where一起使用

1  $User = M("User"); // 實例化User對象
2  $User->where('id=5')->setInc('score',3); // 用戶的積分加3
3  $User->where('id=5')->setInc('score'); // 用戶的積分加1
4  $User->where('id=5')->setDec('score',5); // 用戶的積分減5
5  $User->where('id=5')->setDec('score'); // 用戶的積分減1


上一條消息:

$front = Db::name('area')->where('id', '<', '4')->order('id desc')->limit('0,1')->find();

下一條消息:
$next = Db::name('area')->where('id', '>', '5')->order('id asc')->limit('0,1')->find();

---恢復內容結束---


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM