is it possible to set associations between two objects, for example article
and comment
like this:
comment.setArticle(10) // 10 is the id of article
autogenerated setArtcicle methods takes as argument object Article of course but maybe there are some tricks to do this?
It is very important to me from performance point of view - i would like to avoid making SQL calls always when I want to set an association. In my case there will be plenty of such unnecessary queries.
You can use:
$comment->setArticle($em->getReference('Article', 10));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With