3

I would like to do this request in Doctrine :

IF EXISTS (SELECT * FROM Table1 WHERE Column1='SomeValue')
        UPDATE Table1 SET (...) WHERE Column1='SomeValue'
    ELSE
        INSERT INTO Table1 VALUES (...)

The only way is to do a replace into from what I read (Doctrine docs) but the problem with REPLACE seems to be that it drops and then creates a new row (rather than performing an actual UPDATE)...

Goku
  • 2,157
  • 2
  • 16
  • 31
  • Did you check this question: [implementing "update if exists" in Doctrine ORM](http://stackoverflow.com/questions/1132571/implementing-update-if-exists-in-doctrine-orm) ? – j0k May 28 '13 at 09:08
  • @j0k Yes I check it, but there is no really solution.. – Goku May 28 '13 at 09:13
  • Have you looked at this question: http://stackoverflow.com/questions/1132571/implementing-update-if-exists-in-doctrine-orm a comment mentions this plugin: https://github.com/m14t/m14tDoctrineRecordPlugin – Marcello Romani May 28 '13 at 09:14
  • @MarcelloRomani I work on a professional project, I can't use unofficial plugin. – Goku May 28 '13 at 09:17

0 Answers0