Persisting with Doctrine2 to database with REPLACE

2019-07-21 02:54发布

I have a table where I store relations between two other table with a float indicating relevance between the two rows. I have unique key on the two reference columns. The problem is, that I have to rebuild it regularly, which is kinda lengthy. So, I can't just truncate the table while I'm doing so, but I can't insert the relevance for the same row while they would be duplicates either. That's why I thought it would be great to save the current timestamp to a variable, persist the relations with REPLACE INTO instead of INSERT INTO and then remove everything created before the saved timestamp. However, I couldn't find out how. Any idea? I'm using Doctrine 2.2.0-DEV and Symfony 2.1.0-DEV.

1条回答
Rolldiameter
2楼-- · 2019-07-21 03:27

Doctrine 2 doesn't support INSERT REPLACE or UPSERT, sorry.

查看更多
登录 后发表回答