In Thinkphp, a field value auto-increment or auto-increment function or a field value auto-incrementing function in Thinkphp, this function can be used for the page views of an article/** + ------------------------------------------------ auto-incrementing or auto-incrementing function of a field value in Thinkphp
The auto-increment or auto-incrementing function of a field value in Thinkphp can be used for the page views of the article.
/** + ---------------------- * Auto-increment or auto-increment of a field value + ------------------------ * @ access + -------------------- * @ param string $ model data table name * @ param string $ fields auto-increment or auto field name * @ param integer $ value auto increment or auto increment, the default value is 1 * @ param boolean $ type. the default value is true auto-increment, is false auto-subtract + -------------------- * @ return void + -------------------- */function autoed ($ id = '', $ model ='', $ fields = '', $ value = '', $ type = true) {if (! Empty ($ fields) {if (empty ($ model) {$ name = $ this-> getActionName () ;} else {$ name = $ model ;} $ model = M ($ name); // The default is the primary key ID $ pk = $ model-> getPk (); // The default Auto-increment and auto-increment values are 1 $ value =! Empty ($ value )? $ Value: 1; // if the default value is true, the value is auto-increment. if the value is false, the value is auto-increment. $ type = $ type? "Inc": "Dec"; switch ($ type) {case "Inc": $ model-> setInc ("$ fields", "$ pk = $ id ", $ value); break; case "Dec": $ model-> setDec ("$ fields", "$ pk = $ id", $ value ); $ list = $ model-> field ("$ fields")-> where ("$ pk = $ id")-> find (); if ($ list [$ fields] <= 0) {$ model-> where ("$ pk = $ id")-> setField ("$ fields", 0 );} break ;}}}?