php - Doctrine refresh copy of entity -


i have customeraccount entity. after entity has had changes made via form, before entity has been persisted database, need fetch new copy of same customeraccount entity exists in database. reason need want fire off changed event both old , new data in service.

one hack used $oldaccount = unserialize(serialize($account)); , passing old service, thats hackish.

what really have doctrine pull copy of original entity (while keeping changes new version).

is possible?

update

it appears want impossible @ time way doctrine architected.

update 2

i added solution ended using @ bottom. i'm not happy because feels hackish, gets job done , allows me move on.

it depends.

i mean, doctrine2 use identitymap prevents "accidentally" query db same object on , on again same request. way force doctrine fetch entity object again detach entity entity manager , request entity again.

this, however, lead strange behaviour "slip" out of control:

  • you can't persist again detached object
  • if try persist object related ("linked") detached entity run troubles (and difficult debug)

so, why don't try php built-in clone function? maybe more suitable , save lot of debugging

code example:

$em = $this->getdoctrine()->getmanager(); $fetched_entity = $em->findonbyid(12); $cloned_entity = clone $fetched_entity; //and on ... 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -