使用REPLACE INTO代替INSERT INTO将Doctrine2持续到数据库 [英] Persisting with Doctrine2 to database with REPLACE INTO instead of INSERT INTO

查看:109
本文介绍了使用REPLACE INTO代替INSERT INTO将Doctrine2持续到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中存储两个表之间的关系,浮点指示两行之间的相关性。我在两个参考列上有唯一的键。问题是,我必须定期重建,这是一个很长的。所以,我不能在我这样做时截断表,但我不能插入同一行的相关性,而它们也是重复的。这就是为什么我认为将当前时间戳保存到变量是很好的,与REPLACE INTO保持关系而不是INSERT INTO,然后删除在保存的时间戳之前创建的所有内容。但是,我不知道如何。任何想法?我正在使用Doctrine 2.2.0-DEV和Symfony 2.1.0-DEV。

解决方案

Doctrine 2不支持 INSERT REPLACE UPSERT ,抱歉,


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.

解决方案

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

这篇关于使用REPLACE INTO代替INSERT INTO将Doctrine2持续到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆