thinkphp中的setInc setDec方法

2022-06-29 09:33:27 字數 500 閱讀 4942

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");

thinkphp中的setInc setDec方法

thinkphp中setinc setdec方法 可用於統計字段 通常是數字型別的字段 的更新,例如積分,等級,登陸次數等 必須配合連貫操作where一起使用 1 user m user 例項化user物件 2 user where id 5 setinc score 3 使用者的積分加3 3 us...

thinkphp中的 initialize方法

子類的 initialize方法自動呼叫父類的 initialize方法。而php的建構函式construct,如果要呼叫父類的方法,必須在子類建構函式顯示呼叫parent construct class baseaction extends action 子類如果沒有 initialize方法,則...

ThInkPHP中的常量

除了常規變數的輸出外,模板引擎還支援系統變數和系統常量 以及系統特殊變數的輸出。它們的輸出不需要事先賦值給某個模板變數。系統變數的輸出必須以 think.打頭,並且仍然可以支援使用函式。常用的系統變數輸出包括下面 用法 含義 例子 think.server 獲取 server think.get 獲...