![]() 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/2f1753bf/ |
<?php
// Test Variations Display
require_once 'config/database.php';
echo "<h1>🔍 Testing Variations Display</h1>";
$pdo = getDBConnection();
if (!$pdo) {
echo "<p style='color: red;'>❌ Database connection failed</p>";
exit;
}
echo "<p style='color: green;'>✅ Database connected</p>";
// Get a sample track with variations
try {
$stmt = $pdo->query("
SELECT
mt.id,
mt.title,
mt.variations_count,
mt.status,
COUNT(av.id) as actual_variations
FROM music_tracks mt
LEFT JOIN audio_variations av ON mt.id = av.track_id
WHERE mt.variations_count > 0
GROUP BY mt.id
ORDER BY mt.id ASC
LIMIT 3
");
$tracks = $stmt->fetchAll();
if (!empty($tracks)) {
echo "<h2>📊 Sample Tracks with Variations</h2>";
echo "<table border='1' style='border-collapse: collapse; width: 100%; margin: 20px 0;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>Track ID</th><th>Title</th><th>Variations Count</th><th>Actual Variations</th><th>Status</th>";
echo "</tr>";
foreach ($tracks as $track) {
echo "<tr>";
echo "<td>{$track['id']}</td>";
echo "<td>" . htmlspecialchars($track['title']) . "</td>";
echo "<td>{$track['variations_count']}</td>";
echo "<td>{$track['actual_variations']}</td>";
echo "<td>{$track['status']}</td>";
echo "</tr>";
}
echo "</table>";
// Test the exact query from library.php
echo "<h2>🔍 Testing Library.php Query</h2>";
$stmt = $pdo->prepare("
SELECT
mt.*,
COALESCE(mt.variations_count, 0) as variation_count
FROM music_tracks mt
WHERE mt.id = ?
");
$sampleTrack = $tracks[0];
$stmt->execute([$sampleTrack['id']]);
$testTrack = $stmt->fetch();
echo "<p><strong>Testing track ID:</strong> {$sampleTrack['id']}</p>";
echo "<p><strong>variations_count field:</strong> {$testTrack['variations_count']}</p>";
echo "<p><strong>variation_count alias:</strong> {$testTrack['variation_count']}</p>";
// Test variations fetching
echo "<h2>🎵 Testing Variations Fetching</h2>";
if ($testTrack['variation_count'] > 0) {
echo "<p style='color: green;'>✅ variation_count > 0 condition passed</p>";
$stmt = $pdo->prepare("
SELECT
variation_index,
audio_url,
duration,
title
FROM audio_variations
WHERE track_id = ?
ORDER BY variation_index ASC
");
$stmt->execute([$testTrack['id']]);
$variations = $stmt->fetchAll();
echo "<p><strong>Variations found:</strong> " . count($variations) . "</p>";
if (!empty($variations)) {
echo "<table border='1' style='border-collapse: collapse; width: 100%; margin: 20px 0;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>Index</th><th>Title</th><th>Duration</th><th>Audio URL</th>";
echo "</tr>";
foreach ($variations as $var) {
$audioUrl = $var['audio_url'];
if (strlen($audioUrl) > 50) {
$audioUrl = substr($audioUrl, 0, 50) . '...';
}
echo "<tr>";
echo "<td>{$var['variation_index']}</td>";
echo "<td>" . htmlspecialchars($var['title'] ?? 'N/A') . "</td>";
echo "<td>{$var['duration']}s</td>";
echo "<td>{$audioUrl}</td>";
echo "</tr>";
}
echo "</table>";
}
} else {
echo "<p style='color: red;'>❌ variation_count > 0 condition failed</p>";
}
} else {
echo "<p style='color: orange;'>⚠️ No tracks with variations found</p>";
}
} catch (Exception $e) {
echo "<p style='color: red;'>❌ Error: " . $e->getMessage() . "</p>";
}
echo "<hr>";
echo "<p><em>Test completed at: " . date('Y-m-d H:i:s') . "</em></p>";
?>