Skip to content

Commit 1547f32

Browse files
committed
fix bug when operator not already in table
1 parent ef9996d commit 1547f32

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

resources/lib/UnitySQL.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,14 @@ public function getAllAccountDeletionRequests(): array
198198

199199
public function updateUserLastLogin(string $uid): void
200200
{
201-
$stmt = $this->conn->prepare(
202-
sprintf(
203-
"UPDATE %s SET last_login=CURRENT_TIMESTAMP WHERE operator=:uid",
204-
self::TABLE_USER_LAST_LOGINS,
205-
),
206-
);
201+
$table = self::TABLE_USER_LAST_LOGINS;
202+
$stmt = $this->conn->prepare("
203+
INSERT INTO $table
204+
(operator, last_login)
205+
VALUES(:uid, CURRENT_TIMESTAMP)
206+
ON DUPLICATE KEY UPDATE
207+
last_login=CURRENT_TIMESTAMP
208+
");
207209
$stmt->bindParam(":uid", $uid);
208210
$stmt->execute();
209211
}

0 commit comments

Comments
 (0)