What is the difference between

$em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); 

and

 $em = $this->getDoctrine()->getManager(); $em->refresh($entity); 

Thank.

    1 answer 1

    The difference is very big.

    The persist method performs object saving in the database (or rather, not saving, but preparing it, physically writing to the database occurs when flush called)

    The refresh method re-reads entity data from the database. If you changed any data on the object and did not execute persist , when you call refresh it will be reset.

    • thank you very much for the detailed answer - vladiik