diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-26 14:11:51 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-26 14:11:51 +0500 |
| commit | 7e8a345464d9f18fe3049c2bff2be6e98f1b9cf3 (patch) | |
| tree | 1bc3b8bb9c9c10d5845476f8ca58f8100a846ea0 | |
| parent | c01cdba706b5253a4af0bd5448c13c2e990b9086 (diff) | |
upd: insert User data into uploaded_by
| -rw-r--r-- | public/users.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/public/users.php b/public/users.php index dfa259c..9754b91 100644 --- a/public/users.php +++ b/public/users.php @@ -107,7 +107,7 @@ if ($id == "" && $alias_id == "") { $stmt = null; if ($id != "") { -$stmt = $db->prepare("SELECT * FROM users WHERE id = ?"); + $stmt = $db->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([intval($id)]); } else if ($alias_id != "") { $stmt = $db->prepare("SELECT u.* FROM users u @@ -145,7 +145,7 @@ while ($row = $stmt->fetch()) { // getting info about emote set content $em_stmt = $db->prepare( - "SELECT e.id, e.code, e.ext FROM emotes e + "SELECT e.id, e.code, e.mime, e.ext, e.created_at, e.uploaded_by FROM emotes e INNER JOIN emote_set_contents AS esc ON esc.emote_set_id = ? WHERE esc.emote_id = e.id @@ -153,11 +153,20 @@ while ($row = $stmt->fetch()) { ); $em_stmt->execute([$row["emote_set_id"]]); + $emote_set_emotes = $em_stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($emote_set_emotes as &$e) { + if ($e["uploaded_by"]) { + $uploaded_by_stmt = $db->prepare("SELECT id, username FROM users WHERE id = ?"); + $uploaded_by_stmt->execute([$e["uploaded_by"]]); + $e["uploaded_by"] = $uploaded_by_stmt->fetch(PDO::FETCH_ASSOC); + } + } + $emote_set = [ "id" => $set["id"], "name" => $set["name"], "size" => $set["size"], - "emotes" => $em_stmt->fetchAll(PDO::FETCH_ASSOC) + "emotes" => $emote_set_emotes ]; if ($row["is_default"]) { |
