Welcome Guest, Not a member yet? Register   Sign In
When Does Entity Attributes Get Filled
#2

Entities aren’t filled via the constructor when returned as part of a database query result (this includes Models), but rather have each attribute set one at a time. See e.g.:
https://github.com/codeigniter4/CodeIgni...t.php#L179

You could probably create your own magic getter for posts that would load it on-the-fly, but I’m not entirely sure of its interaction with toArray(). I use this kind of “lazy load” for my Relations Entity trait and it works very well - no extra loading of related items if you don’t need them.
Reply


Messages In This Thread
RE: When Does Entity Attributes Get Filled - by MGatner - 12-12-2019, 08:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB