You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 72e8db0
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/models/entities.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -863,3 +863,5 @@ The direct call to `injectRawData()` illustrates what happens when a model confi
863
863
An attribute retained after loading may differ from the value stored in the database. For example, suppose the `isBanned` column contains `'1'`. If the query selects only `id` and `role`, the loaded entity retains its default of `'0'` for `isBanned`.
864
864
865
865
With [`$updateOnlyChanged`](model.md#updateonlychanged) enabled (the default), changing `role` and updating the entity leaves the stored `isBanned` value alone. With `$updateOnlyChanged` disabled, the same update can also write `'0'` to `isBanned` if the field is in [`$allowedFields`](model.md#allowedfields). To update just the role, pass `['role' => $newRole]` to the model's `update()` method.
866
+
867
+
When `$skipValidation = false` and [`$cleanValidationRules = false`](model.md#cleanvalidationrules), `BaseModel::transformDataToArray()` extracts all attributes regardless of `$updateOnlyChanged`. Retained defaults can therefore overwrite omitted database columns even with `$updateOnlyChanged = true`.
0 commit comments