add:新增字段自增/减少方法

This commit is contained in:
JaguarJack 2020-11-04 14:09:23 +08:00
parent 7c4fa5c516
commit c8e9e6361c

View File

@ -230,4 +230,32 @@ class CatchQuery extends Query
return $this; return $this;
} }
/**
* 字段增加
*
* @time 2020年11月04日
* @param $field
* @param int $amount
* @throws \think\db\exception\DbException
* @return int
*/
public function increment($field, $amount = 1)
{
return $this->inc($field, $amount)->update();
}
/**
* 字段减少
*
* @time 2020年11月04日
* @param $field
* @param int $amount
* @throws \think\db\exception\DbException
* @return int
*/
public function decrement($field, $amount = 1)
{
return $this->dec($field, $amount)->update();
}
} }