This commit is contained in:
2021-08-06 18:05:50 +08:00
parent 26fc318af5
commit 99ddfe268e
+6 -9
View File
@@ -538,17 +538,14 @@ 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 false; return $this->insert($change, $fields);
} }
@@ -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 = [];