After you flush the $em
it happens (it is commited) in database.. so... you might want to retrieve the $db_entity
before flush()
I am not sure what you want.. but you can also use
merge
instead ofpersist
.merge
is returning the object modified - id generated and settedpersist
is modifying your instance
If you want to have the object modified and not
persisted
use it beforeflush
.EntityManager
is giving you the same instance because you didn't$em->clear()
flush
is commiting all changes (alldirty
objects)clear
is clearing memory cache. so when youfind(..., $id)
, you will get a brand new instance
- Is
clone
keyword working for you? like in this example:
$entity = $em->find('My\Entity', $id);
$clonedEntity = clone $entity;
And you might also want to read this: Implementing Wakeup or Clone