This is more of a support question, but I couldn’t find any better place to ask. Please tell me if there is.
I don’t understand what is the proper way to retrieve relations on a single entity, that I got via $repo->findByPK(…).
I figured out I can do $repo->select()->wherePK(…)->load("country")->fetchOne(), but is that the "usual" way? I’m starting to understand that it’s not the entity’s job to "load things," so I guess it makes sense.
Also the docs (Basics > Simple Relation) uses type hints on the getter:
public function getAddress(): ?Address
But if I do that and use $repo->findByPK(…) and then call my getter, I get an error because the property contains a Cycle\ORM\Promise\Reference.
Can I do anything with this Reference class? It doesn’t seem to even contain the ID of the related entity.
Should I forget about type hints for relation accessors?
Should I forget about the findByPK method?
This is more of a support question, but I couldn’t find any better place to ask. Please tell me if there is.
I don’t understand what is the proper way to retrieve relations on a single entity, that I got via
$repo->findByPK(…).I figured out I can do
$repo->select()->wherePK(…)->load("country")->fetchOne(), but is that the "usual" way? I’m starting to understand that it’s not the entity’s job to "load things," so I guess it makes sense.Also the docs (Basics > Simple Relation) uses type hints on the getter:
But if I do that and use
$repo->findByPK(…)and then call my getter, I get an error because the property contains a Cycle\ORM\Promise\Reference.Can I do anything with this Reference class? It doesn’t seem to even contain the ID of the related entity.
Should I forget about type hints for relation accessors?
Should I forget about the
findByPKmethod?