When Does Entity Attributes Get Filled |
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. |
Messages In This Thread |
When Does Entity Attributes Get Filled - by viewfromthenorth - 12-11-2019, 08:31 PM
RE: When Does Entity Attributes Get Filled - by MGatner - 12-12-2019, 08:12 PM
RE: When Does Entity Attributes Get Filled - by mlurie - 09-24-2020, 04:51 PM
|