Initial commit (code), runtime ignoré, secrets exclus
This commit is contained in:
67
show_table_structure.php
Normal file
67
show_table_structure.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
require_once '/var/www/mathematiques/config/database.php';
|
||||
$db = Database::getInstance()->getConnection();
|
||||
|
||||
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'>";
|
||||
echo "<style>
|
||||
body { font-family: monospace; padding: 20px; background: #f5f5f5; }
|
||||
h1, h2 { color: #333; }
|
||||
table { border-collapse: collapse; width: 100%; margin: 20px 0; background: white; }
|
||||
th, td { border: 1px solid #ddd; padding: 12px; text-align: left; }
|
||||
th { background: #667eea; color: white; }
|
||||
.required { color: red; font-weight: bold; }
|
||||
.nullable { color: green; }
|
||||
pre { background: #f0f0f0; padding: 15px; border-radius: 5px; overflow-x: auto; }
|
||||
</style></head><body>";
|
||||
|
||||
echo "<h1>🔍 Structure complète de la table 'classes'</h1>";
|
||||
|
||||
// 1. Structure de la table
|
||||
echo "<h2>📊 Colonnes de la table</h2>";
|
||||
echo "<table>";
|
||||
echo "<tr><th>Colonne</th><th>Type</th><th>NULL autorisé</th><th>Valeur par défaut</th><th>Extra</th></tr>";
|
||||
|
||||
$stmt = $db->query("DESCRIBE classes");
|
||||
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($columns as $col) {
|
||||
$null_status = $col['Null'] == 'NO' ? "<span class='required'>NON (obligatoire)</span>" : "<span class='nullable'>OUI</span>";
|
||||
$default = $col['Default'] ?? '<em>NULL</em>';
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td><strong>{$col['Field']}</strong></td>";
|
||||
echo "<td>{$col['Type']}</td>";
|
||||
echo "<td>$null_status</td>";
|
||||
echo "<td>$default</td>";
|
||||
echo "<td>{$col['Extra']}</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
// 2. Classes existantes
|
||||
echo "<h2>📋 Classes existantes</h2>";
|
||||
$stmt = $db->query("SELECT * FROM classes LIMIT 3");
|
||||
$existing = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($existing)) {
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach (array_keys($existing[0]) as $key) {
|
||||
echo "<th>$key</th>";
|
||||
}
|
||||
echo "</tr>";
|
||||
|
||||
foreach ($existing as $row) {
|
||||
echo "<tr>";
|
||||
foreach ($row as $value) {
|
||||
echo "<td>" . htmlspecialchars($value ?? 'NULL') . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<p><em>Aucune classe existante</em></p>";
|
||||
}
|
||||
|
||||
echo "</body></html>";
|
||||
?>
|
||||
Reference in New Issue
Block a user