<?php
try {
    $conn = new PDO('mysql:host=localhost;dbname=elevators_management', 'root', '');
    $stmt = $conn->query('SHOW COLUMNS FROM chart_of_accounts');

    echo "Chart of Accounts Table Structure:\n";
    echo "--------------------------------\n";

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        echo $row['Field'] . ' | ' . $row['Type'] . ' | ' . $row['Null'] . ' | ' . $row['Key'] . ' | ' . $row['Default'] . ' | ' . $row['Extra'] . "\n";
    }

    // Check for any constraints or unique indexes
    $stmt = $conn->query('SHOW INDEXES FROM chart_of_accounts');

    echo "\nChart of Accounts Indexes:\n";
    echo "-------------------------\n";

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        echo $row['Key_name'] . ' | ' . $row['Column_name'] . ' | ' . ($row['Non_unique'] ? 'Non-unique' : 'Unique') . "\n";
    }
} catch (PDOException $e) {
    echo 'Error: ' . $e->getMessage();
}
