doctrine: setting association with id instead of object instance
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.
Solution 1:
You can use:
$comment->setArticle($em->getReference('Article', 10));