Prechádzať zdrojové kódy

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

Yahoo 4 rokov pred
rodič
commit
975aa5750b
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  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();
     }