How to check if entity changed in Doctrine 2?

前端 未结 9 745
盖世英雄少女心
盖世英雄少女心 2020-12-23 20:53

I need to check if a persisted entity has changed and needs to be updated on the database. What I made (and did not work) was the following:

$product = $enti         


        
9条回答
  •  鱼传尺愫
    2020-12-23 21:16

    Doctrine2 Docs. 17. Change Tracking Policies

    If you use third form (17.3. Notify) as i do, you can test if your entity is changed doing:

    $uow = $entityManager->getUnitOfWork();
    $uow->computeChangeSets();
    $aChangeSet = $uow->getEntityChangeSet($oEntity);
    

    If nothing changed it will return blank array.

提交回复
热议问题