瀏覽代碼

修复:模型setDec方法不支持传参主键ID

Yahoo 4 年之前
父節點
當前提交
975aa5750b
共有 1 個文件被更改,包括 3 次插入 和 0 次删除
  1. 3 0
      cores/BaseModel.php

+ 3 - 0
cores/BaseModel.php

@@ -244,6 +244,9 @@ abstract class BaseModel extends Model
      */
     protected function setDec($where, string $field, float $step = 1)
     {
+        if (is_numeric($where)) {
+            $where = [$this->getPk() => (int)$where];
+        }
         return $this->where($where)->dec($field, $step)->update();
     }