This commit is contained in:
2021-08-06 18:05:50 +08:00
parent 26fc318af5
commit 99ddfe268e
+3 -6
View File
@@ -538,18 +538,15 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
if (!is_null($data)) { if (!is_null($data)) {
$this->_attributes = merge($this->_attributes, $data); $this->_attributes = merge($this->_attributes, $data);
} }
if (!$this->validator($this->rules())) { if (!$this->validator($this->rules()) || !$this->beforeSave($this)) {
return false; return false;
} }
if ($this->beforeSave($this)) { [$change, $condition, $fields] = $this->separation();
[$change, $condition, $fields] = $this->filtration_and_separation();
if (!$this->isNewExample) { if (!$this->isNewExample) {
return $this->updateInternal($fields, $condition, $change); return $this->updateInternal($fields, $condition, $change);
} }
return $this->insert($change, $fields); return $this->insert($change, $fields);
} }
return false;
}
/** /**
@@ -618,7 +615,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
private function filtration_and_separation(): array private function separation(): array
{ {
$_tmp = []; $_tmp = [];
$condition = []; $condition = [];