@@ -778,6 +778,8 @@ public function save(array | object $data = [], $where = []): bool
778778 $ this ->relationSave ($ relations );
779779 }
780780
781+ // 重置原始数据
782+ $ this ->setWeakMap ('origin ' , $ data );
781783 return true ;
782784 }
783785
@@ -798,7 +800,7 @@ protected function autoDateTime(array &$data, bool $update)
798800 foreach ($ dateTimeFields as $ field ) {
799801 if (is_string ($ field )) {
800802 $ data [$ field ] = $ this ->getDateTime ($ field );
801- $ this ->$ field = $ this ->readTransform ($ data [$ field ], $ this ->getFields ($ field ));
803+ $ this ->setData ( $ field, $ this ->readTransform ($ data [$ field ], $ this ->getFields ($ field) ));
802804 }
803805 }
804806 }
@@ -926,6 +928,7 @@ public function isSimple(): bool
926928 public function delete (): bool
927929 {
928930 if ($ this ->isVirtual () || $ this ->isView ()) {
931+ $ this ->clear ();
929932 return true ;
930933 }
931934
@@ -948,6 +951,7 @@ public function delete(): bool
948951 $ this ->relationDelete ($ relations );
949952 }
950953
954+ $ this ->clear ();
951955 return true ;
952956 }
953957
@@ -1099,6 +1103,20 @@ public function data(array $data)
10991103 return $ this ;
11001104 }
11011105
1106+ /**
1107+ * 清空模型数据.
1108+ *
1109+ * @return $this
1110+ */
1111+ public function clear ()
1112+ {
1113+ self ::$ weakMap [$ this ]['data ' ] = [];
1114+ self ::$ weakMap [$ this ]['origin ' ] = [];
1115+ self ::$ weakMap [$ this ]['get ' ] = [];
1116+ self ::$ weakMap [$ this ]['relation ' ] = [];
1117+ return $ this ;
1118+ }
1119+
11021120 /**
11031121 * 获取原始数据.
11041122 *
0 commit comments