![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-69bd013c/ |
<?php
header('Content-Type: application/json');
require_once '../config/database.php';
$pdo = getDBConnection();
$artist_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($artist_id <= 0) {
echo json_encode(['success' => false, 'error' => 'Invalid artist ID']);
exit;
}
try {
// Get artist tracks
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.prompt,
mt.audio_url,
mt.duration,
mt.created_at,
mt.status,
u.name as artist_name,
u.id as artist_id,
(SELECT COUNT(*) FROM track_likes WHERE track_id = mt.id) as like_count,
(SELECT COUNT(*) FROM track_comments WHERE track_id = mt.id) as comment_count,
(SELECT COUNT(*) FROM track_plays WHERE track_id = mt.id) as play_count
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.user_id = ? AND mt.status = 'complete'
ORDER BY mt.created_at DESC
");
$stmt->execute([$artist_id]);
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode([
'success' => true,
'tracks' => $tracks,
'count' => count($tracks)
]);
} catch (Exception $e) {
echo json_encode([
'success' => false,
'error' => 'Database error: ' . $e->getMessage()
]);
}
?>