pg support of duplicate key update

This commit is contained in:
xiaomlove
2026-04-25 03:22:38 +07:00
parent dc77ab7b40
commit 7d18a7f76a
14 changed files with 62 additions and 29 deletions
+2 -2
View File
@@ -566,8 +566,8 @@ if (($left > 0 || $event == "completed") && $az['class'] < \App\Models\HitAndRun
if ($snatchInfo['downloaded'] >= $requiredDownloaded) {
$nowStr = date('Y-m-d H:i:s');
$sql = sprintf(
"insert into hit_and_runs (uid, torrent_id, snatched_id, created_at, updated_at) values (%d, %d, %d, '%s', '%s') on duplicate key update updated_at = '%s'",
$userid, $torrentid, $snatchInfo['id'], $nowStr, $nowStr, $nowStr
"insert into hit_and_runs (uid, torrent_id, snatched_id, created_at, updated_at) values (%d, %d, %d, '%s', '%s') %s",
$userid, $torrentid, $snatchInfo['id'], $nowStr, $nowStr, \Nexus\Database\NexusDB::upsertField(['uid', 'torrent_id'], ['updated_at'])
);
$affectedRows = sql_query($sql);
$hitAndRunId = mysql_insert_id();