I am trying to INSERT OR UPDATE IF EXISTS in one transaction.
INSERT OR UPDATE IF EXISTS
in mysql, I would generally use DUPLICATE KEY (\"UPDATE ON
DUPLICATE KEY
Doctrine supports REPLACE INTO using the replace() method. This should work exactly like the ON DUPLICATE KEY UPDATE you were looking for.
REPLACE INTO
replace()
ON DUPLICATE KEY UPDATE
Docs: Replacing Records