File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -826,12 +826,22 @@ public function save(array | object $data = [], $where = []): bool
826826
827827 $ model = $ this ->model ();
828828 if ($ model instanceof Model) {
829- $ result = $ model ->allowField ($ allow )->setUpdateWhere ($ where )->save ($ data );
829+ if (!empty ($ where )) {
830+ $ model ->setUpdateWhere ($ where );
831+ } else {
832+ $ model ->setKey ($ this ->getKey ());
833+ }
834+ $ result = $ model ->allowField ($ allow )->save ($ data );
830835 if (false === $ result ) {
831836 return false ;
832837 }
833838 } else {
834- $ result = $ model ->field ($ allow )->where ($ where )->save ($ data , !$ isUpdate );
839+ if (!empty ($ where )) {
840+ $ model ->where ($ where );
841+ } else {
842+ $ model ->setKey ($ this ->getKey ());
843+ }
844+ $ result = $ model ->field ($ allow )->save ($ data , !$ isUpdate );
835845 if (!$ isUpdate ) {
836846 $ this ->setKey ($ model ->getLastInsID ());
837847 }
You can’t perform that action at this time.
0 commit comments