How to check if entity changed in Doctrine 2?

前端 未结 9 747
盖世英雄少女心
盖世英雄少女心 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:07

    I didn't need/want to create Listeners for my case so I ended up with

    $product->setName('A different name');
    $uow = $entityManager->getUnitOfWork();
    $uow->computeChangeSets();
    if ($uow->isEntityScheduled($product)) {
        // My entity has changed
    }
    

提交回复
热议问题