j9rcoa
Last Updated: February 25, 2016
·
1.165K
· devalien
C636c24e8d4ea2d70460f72501d60c31

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);

Say Thanks
Respond