Sindbad~EG File Manager
<?php
/**
* Database Schema Checker
* Checks the current structure of the members table
*/
require_once '../config/config.php';
try {
$db = Database::getInstance()->getConnection();
echo "<h2>Database Schema Check</h2>\n";
echo "<h3>Members Table Structure:</h3>\n";
// Get table structure
$stmt = $db->query("DESCRIBE members");
$columns = $stmt->fetchAll();
echo "<table border='1' cellpadding='5' cellspacing='0'>\n";
echo "<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>\n";
$membershipCardIdExists = false;
foreach ($columns as $column) {
echo "<tr>";
echo "<td>" . htmlspecialchars($column['Field']) . "</td>";
echo "<td>" . htmlspecialchars($column['Type']) . "</td>";
echo "<td>" . htmlspecialchars($column['Null']) . "</td>";
echo "<td>" . htmlspecialchars($column['Key']) . "</td>";
echo "<td>" . htmlspecialchars($column['Default']) . "</td>";
echo "<td>" . htmlspecialchars($column['Extra']) . "</td>";
echo "</tr>\n";
if ($column['Field'] === 'membershipcard_id') {
$membershipCardIdExists = true;
}
}
echo "</table>\n";
if ($membershipCardIdExists) {
echo "<p style='color: green;'>✅ membershipcard_id column EXISTS</p>\n";
// Check sample data
$stmt = $db->query("SELECT id, membershipcard_id, first_name, last_name FROM members LIMIT 5");
$members = $stmt->fetchAll();
if ($members) {
echo "<h3>Sample Data:</h3>\n";
echo "<table border='1' cellpadding='5' cellspacing='0'>\n";
echo "<tr><th>ID</th><th>Membership Card ID</th><th>First Name</th><th>Last Name</th></tr>\n";
foreach ($members as $member) {
echo "<tr>";
echo "<td>" . htmlspecialchars($member['id']) . "</td>";
echo "<td>" . htmlspecialchars($member['membershipcard_id']) . "</td>";
echo "<td>" . htmlspecialchars($member['first_name']) . "</td>";
echo "<td>" . htmlspecialchars($member['last_name']) . "</td>";
echo "</tr>\n";
}
echo "</table>\n";
}
} else {
echo "<p style='color: red;'>❌ membershipcard_id column DOES NOT EXIST</p>\n";
echo "<p>You need to run the migration to add this column.</p>\n";
echo "<p><a href='run_migration.php'>Run Migration</a></p>\n";
}
} catch (PDOException $e) {
echo "<p style='color: red;'>❌ Database error: " . $e->getMessage() . "</p>\n";
} catch (Exception $e) {
echo "<p style='color: red;'>❌ Error: " . $e->getMessage() . "</p>\n";
}
echo "<hr>";
echo "<p><a href='../dashboard.php'>← Back to Dashboard</a></p>";
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists