修正自动验证唯一性的一个BUG

This commit is contained in:
thinkphp
2015-12-25 18:13:36 +08:00
parent 053801d8d5
commit 736a451a44

View File

@@ -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]);
}