public function setInc($field, $step = 1, $lazyTime = 0)
{
$condition = !empty($this->options['where']) ? $this->options['where'] : [];
if (empty($condition)) {
// 没有条件不做任何更新
throw new Exception('no data to update');
}
if ($lazyTime > 0) {
// 延迟写入
$guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition));
$step = $this->lazyWrite('inc', $guid, $step, $lazyTime);
if (false === $step) {
// 清空查询条件
$this->options = [];
return true;
} else {
return $this->setField($field, $step);
}
}
return $this->setField($field, ['exp', $field . '+' . $step]);
}