implementing “update if exists” in Doctrine ORM

后端 未结 4 1952
野趣味
野趣味 2020-12-10 01:46

I am trying to INSERT OR UPDATE IF EXISTS in one transaction.

in mysql, I would generally use DUPLICATE KEY (\"UPDATE ON

4条回答
  •  醉梦人生
    2020-12-10 01:48

    I think best way is to call entityManager->merge($entity); Because it's the closest thing to update if exist operation as promised in documentation: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/working-with-objects.html

提交回复
热议问题