From 736a451a44d63b009a34df0551e3b2af9fc1c1d1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 25 Dec 2015 18:13:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=87=AA=E5=8A=A8=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=94=AF=E4=B8=80=E6=80=A7=E7=9A=84=E4=B8=80=E4=B8=AA?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/traits/model/auto.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/traits/model/auto.php b/library/traits/model/auto.php index a52038ab..99d51214 100644 --- a/library/traits/model/auto.php +++ b/library/traits/model/auto.php @@ -303,11 +303,17 @@ trait Auto } else { $map[$val[0]] = $data[$val[0]]; } - if (!empty($data[$this->getPk()])) { + $pk = $this->getPk(); + if (!empty($data[$pk]) && is_string($pk)) { // 完善编辑的时候验证唯一 - $map[$this->getPk()] = ['neq', $data[$this->getPk()]]; + $map[$pk] = ['neq', $data[$pk]]; } - return $this->where($map)->find() ? false : true; + $options = $this->options; + if ($this->where($map)->find()) { + return false; + } + $this->options = $options; + return true; default: // 检查附加规则 return $this->check($data[$val[0]], $val[1], $val[4]); }