Last Updated: February 25, 2016
·
2.428K
· devalien

Doctrine using an id instead of passing the object

For example you get a list of IDS and you don't need to get an object querying the database, you can do just a simple trick.
$em->getReference('ENTITY',$id);

Example:
$post->setCategory('Category', $id);

or in symfony:
$post->setCategory('CompanyNameBundle:Category', $id);