add:新增字段自增/减少方法
This commit is contained in:
parent
7c4fa5c516
commit
c8e9e6361c
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user