From d69bc6c601cdeeef2d673a4dab1d768bfb0a7fe5 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 13 Dec 2017 13:54:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BValidate=E7=B1=BB=E7=9A=84uni?= =?UTF-8?q?que=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index b03d5cba..3903fffc 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -837,13 +837,14 @@ class Validate $map[$key] = $data[$field]; } - $pk = strval(isset($rule[3]) ? $rule[3] : $db->getPk()); - if (isset($rule[2])) { - $map[$pk] = ['neq', $rule[2]]; - } elseif (isset($data[$pk])) { - $map[$pk] = ['neq', $data[$pk]]; + $pk = isset($rule[3]) ? $rule[3] : $db->getPk(); + if (is_string($pk)) { + if (isset($rule[2])) { + $map[$pk] = ['neq', $rule[2]]; + } elseif (isset($data[$pk])) { + $map[$pk] = ['neq', $data[$pk]]; + } } - if ($db->where($map)->field($pk)->find()) { return false; }