Just wondering if there is an easy way to auto-populate an object’s related fields on an instance-by-instance basis rather than globally in the config file, or, for the entire class.
I’d like to include all related models for a single instance without chaining a ton of include_related() functions.
Something like this would be nice:
$x = new Model();
$x->include_all_related();
Thought I’d have to get my hands dirty in the core. For whatever reason, it didn’t occur to me that I could access the
$has_manyand$has_onearrays.Solution was simple:
You might wonder why I’m using the
classkey in the$hvariable. Under the hood, Datamapper ORM keeps track of some other keys too as part of a bigger array. If you callprint_r($h), you can see them. Theclasskey keeps track offoo,barandbaz.