Make getAccountProfile.php and getAccountProfileMessages.php work with new db method

This commit is contained in:
2025-12-31 23:31:52 -07:00
parent 2d78565f77
commit 34328de9b6
2 changed files with 30 additions and 10 deletions

View File

@@ -7,16 +7,24 @@ $post = getPostData();
$targetId = (int)$post['targetId'] ?? 0;
$stmt = $conn->prepare("
SELECT p.id, p.content, p.timestamp, p.likes, u.id as userId
FROM userposts p
JOIN users u ON p.userId = u.id
WHERE u.id = ? AND p.deleted_at = 0
ORDER BY p.id DESC
SELECT id, content, timestamp, likes, userId
FROM userposts
WHERE userId = ? AND deleted_at = 0
ORDER BY id DESC
");
$stmt->bind_param("i", $targetId);
$stmt->execute();
$result = $stmt->get_result();
echo encrypt(json_encode(array_map(fn($row) => ['id' => $row['id'], 'userId' => $row['userId'], 'content' => $row['content'], 'timestamp' => genTimestamp($row['timestamp']) . " ago", 'likes' => $row['likes']], $result->fetch_all(MYSQLI_ASSOC))));
echo encrypt(json_encode(array_map(
fn($row) => [
'id' => $row['id'],
'userId' => $row['userId'],
'content' => $row['content'],
'timestamp' => genTimestamp($row['timestamp']) . " ago",
'likes' => $row['likes']
],
$result->fetch_all(MYSQLI_ASSOC)
)));
$conn->close();