给数据库某一字段自增某一个数值
2016-11-21 本文已影响0人
GQ1994
虽然简单,但是刻骨铭心的记忆啊!
直接上代码
/**
* 给某个字段自增n
* @author 郭庆
*/
public static function incrementData($where,$field,$n)
{
return DB::table(self::$table)->where($where)->increment($field,$n);
}
第一个参数,那一条记录,数组
第二个参数,哪个字段自增
第三个参数,自增的量