MySql - 在重复键上

时间:2016-04-13 20:10:50

标签: mysql on-duplicate-key

我有一张桌子:

Saves
-----
UserId (int primary key)
Save (blob)
SaveBackup (blob)

这是填充:

Saves(22, 'xyz', '')

我提交以下内容:

$stmt = $db->prepare("INSERT INTO Saves (UserId, Save, SaveBackup) "
                        . "VALUES (:UserId1, :Save1, '') ON DUPLICATE KEY "
                        . "UPDATE Saves SET SaveBackup=Save, Save=:Save2 "
                        . "WHERE UserId=:UserId2");
$stmt->execute(array(':Save1' => 'zzz',
                ':Save2' => 'zzz',
                ':UserId1' => 22,
                ':UserId2' => 22));

它不起作用,SQL代码中的错误。它工作正常,没有所有东西(包括)ON DUPLICATE KEY。

0 个答案:

没有答案