Update an Entity with Unique Key - Insert instead of update

后端 未结 2 795
小鲜肉
小鲜肉 2021-01-14 11:19

I have this method in my service:

public function updateCountry($p_entity) {   


    var_dump($p_entity->getId());    //return 3 (as expected)
    var_du         


        
2条回答
  •  星月不相逢
    2021-01-14 11:51

    You shouldn't persist existing in DB entity, only new one. So if you get entity from DB and want to update it you should

    1. $entity->setName()
    2. $em->flush

提交回复
热议问题