![]() 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/-1095d0fb/ |
<?php
// Check Library Database Tables
session_start();
require_once 'config/database.php';
echo "<h1>🔍 Library Database Structure Check</h1>";
$pdo = getDBConnection();
if (!$pdo) {
die("Database connection failed");
}
// Get all tables
$tables = $pdo->query("SHOW TABLES")->fetchAll(PDO::FETCH_COLUMN);
echo "<h2>📋 All Database Tables:</h2>";
echo "<ul>";
foreach ($tables as $table) {
echo "<li><strong>$table</strong></li>";
}
echo "</ul>";
// Check music_tracks table structure
echo "<h2>🎵 Music Tracks Table Structure:</h2>";
try {
$stmt = $pdo->query("DESCRIBE music_tracks");
$columns = $stmt->fetchAll();
echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
echo "<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>";
foreach ($columns as $col) {
echo "<tr>";
echo "<td>{$col['Field']}</td>";
echo "<td>{$col['Type']}</td>";
echo "<td>{$col['Null']}</td>";
echo "<td>{$col['Key']}</td>";
echo "<td>{$col['Default']}</td>";
echo "<td>{$col['Extra']}</td>";
echo "</tr>";
}
echo "</table>";
} catch (Exception $e) {
echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
// Check audio_variations table structure
echo "<h2>🎼 Audio Variations Table Structure:</h2>";
try {
$stmt = $pdo->query("DESCRIBE audio_variations");
$columns = $stmt->fetchAll();
echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
echo "<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>";
foreach ($columns as $col) {
echo "<tr>";
echo "<td>{$col['Field']}</td>";
echo "<td>{$col['Type']}</td>";
echo "<td>{$col['Null']}</td>";
echo "<td>{$col['Key']}</td>";
echo "<td>{$col['Default']}</td>";
echo "<td>{$col['Extra']}</td>";
echo "</tr>";
}
echo "</table>";
} catch (Exception $e) {
echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
// Check sample data in music_tracks
echo "<h2>📊 Sample Music Tracks Data:</h2>";
try {
$stmt = $pdo->query("SELECT id, user_id, title, music_type, status, duration, created_at FROM music_tracks LIMIT 5");
$tracks = $stmt->fetchAll();
if (empty($tracks)) {
echo "<p>No tracks found in database</p>";
} else {
echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
echo "<tr><th>ID</th><th>User ID</th><th>Title</th><th>Type</th><th>Status</th><th>Duration</th><th>Created</th></tr>";
foreach ($tracks as $track) {
echo "<tr>";
echo "<td>{$track['id']}</td>";
echo "<td>{$track['user_id']}</td>";
echo "<td>{$track['title']}</td>";
echo "<td>{$track['music_type']}</td>";
echo "<td>{$track['status']}</td>";
echo "<td>{$track['duration']}</td>";
echo "<td>{$track['created_at']}</td>";
echo "</tr>";
}
echo "</table>";
}
} catch (Exception $e) {
echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
// Check sample data in audio_variations
echo "<h2>🎵 Sample Audio Variations Data:</h2>";
try {
$stmt = $pdo->query("SELECT id, track_id, variation_index, title, duration, created_at FROM audio_variations LIMIT 5");
$variations = $stmt->fetchAll();
if (empty($variations)) {
echo "<p>No variations found in database</p>";
} else {
echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
echo "<tr><th>ID</th><th>Track ID</th><th>Variation Index</th><th>Title</th><th>Duration</th><th>Created</th></tr>";
foreach ($variations as $var) {
echo "<tr>";
echo "<td>{$var['id']}</td>";
echo "<td>{$var['track_id']}</td>";
echo "<td>{$var['variation_index']}</td>";
echo "<td>{$var['title']}</td>";
echo "<td>{$var['duration']}</td>";
echo "<td>{$var['created_at']}</td>";
echo "</tr>";
}
echo "</table>";
}
} catch (Exception $e) {
echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
// Check track counts
echo "<h2>📈 Track Statistics:</h2>";
try {
$stmt = $pdo->query("SELECT COUNT(*) as total_tracks FROM music_tracks");
$total = $stmt->fetch();
echo "<p><strong>Total Tracks:</strong> {$total['total_tracks']}</p>";
$stmt = $pdo->query("SELECT COUNT(*) as total_variations FROM audio_variations");
$total_var = $stmt->fetch();
echo "<p><strong>Total Variations:</strong> {$total_var['total_variations']}</p>";
$stmt = $pdo->query("SELECT status, COUNT(*) as count FROM music_tracks GROUP BY status");
$status_counts = $stmt->fetchAll();
echo "<p><strong>Status Breakdown:</strong></p><ul>";
foreach ($status_counts as $status) {
echo "<li>{$status['status']}: {$status['count']}</li>";
}
echo "</ul>";
} catch (Exception $e) {
echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
// Check for any other related tables
echo "<h2>🔗 Related Tables Check:</h2>";
$related_tables = ['track_likes', 'track_plays', 'track_comments', 'track_shares', 'track_views'];
foreach ($related_tables as $table) {
try {
$stmt = $pdo->query("SELECT COUNT(*) as count FROM $table");
$count = $stmt->fetch();
echo "<p><strong>$table:</strong> {$count['count']} records</p>";
} catch (Exception $e) {
echo "<p><strong>$table:</strong> <span style='color: red;'>Table does not exist</span></p>";
}
}
echo "<hr>";
echo "<p><em>Database check completed at: " . date('Y-m-d H:i:s') . "</em></p>";
?>