mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Validate类的unique验证
This commit is contained in:
@@ -837,13 +837,14 @@ class Validate
|
||||
$map[$key] = $data[$field];
|
||||
}
|
||||
|
||||
$pk = strval(isset($rule[3]) ? $rule[3] : $db->getPk());
|
||||
$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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user