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
As of current, ActiveRecord::refresh() and BaseActiveRecord::refresh() only refresh the record itself and lose all relations. This is the expected behaviour, but if you then need to iterate over nested relations afterwards, lazy loading them leads to an excessive amount of DB queries.
My proposal would thus be to add an optional parameter with to refresh:
public function refresh ($with = [])
The implementation in ActiveRecord uses the corresponding model's ActiveQuery anyway, so it might as well call ->with(...$with) on it in the process.
Q
A
Yii version
dev-master
PHP version
8.1
Operating system
Debian 12
I'd be happy to implement this, but want to be sure this makes sense and I haven't missed anything relevant before :)
The text was updated successfully, but these errors were encountered:
As of current,
ActiveRecord::refresh()
andBaseActiveRecord::refresh()
only refresh the record itself and lose all relations. This is the expected behaviour, but if you then need to iterate over nested relations afterwards, lazy loading them leads to an excessive amount of DB queries.My proposal would thus be to add an optional parameter
with
torefresh
:public function refresh ($with = [])
The implementation in
ActiveRecord
uses the corresponding model'sActiveQuery
anyway, so it might as well call->with(...$with)
on it in the process.I'd be happy to implement this, but want to be sure this makes sense and I haven't missed anything relevant before :)
The text was updated successfully, but these errors were encountered: