forked from imabutahersiddik/CodeStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile_system.php
More file actions
54 lines (51 loc) · 1.58 KB
/
profile_system.php
File metadata and controls
54 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
class UserProfile {
private $pdo;
private $userId;
private $currentTime;
public function __construct($pdo, $userId) {
$this->pdo = $pdo;
$this->userId = $userId;
$this->currentTime = '2025-06-14 12:47:29'; // Using provided UTC time
}
public function getProfileData() {
$stmt = $this->pdo->prepare("
SELECT
u.*,
COUNT(DISTINCT a.id) as total_apps,
COUNT(DISTINCT ar.id) as total_reviews,
SUM(a.downloads_count) as total_downloads
FROM users u
LEFT JOIN apps a ON u.id = a.user_id
LEFT JOIN app_ratings ar ON u.id = ar.user_id
WHERE u.id = ?
GROUP BY u.id
");
$stmt->execute([$this->userId]);
return $stmt->fetch();
}
public function getActivityTimeline() {
$stmt = $this->pdo->prepare("
(SELECT
'app_submission' as type,
app_name as title,
submitted_at as timestamp,
id as reference_id
FROM apps
WHERE user_id = ?)
UNION ALL
(SELECT
'app_rating' as type,
(SELECT app_name FROM apps WHERE id = app_id) as title,
created_at as timestamp,
app_id as reference_id
FROM app_ratings
WHERE user_id = ?)
ORDER BY timestamp DESC
LIMIT 10
");
$stmt->execute([$this->userId, $this->userId]);
return $stmt->fetchAll();
}
}
?>