<?php

require_once __DIR__ . '/Include/Config.php';
require_once __DIR__ . '/Include/PageInit.php';

use Propel\Runtime\Propel;

try {
    $pdo = Propel::getConnection();
    
    // Check if table exists
    $sql = "SHOW TABLES LIKE 'expense_exp'";
    $result = $pdo->query($sql);
    $tables = $result->fetchAll();
    
    echo "<h3>Database Tables:</h3>";
    echo "<pre>";
    print_r($tables);
    echo "</pre>";
    
    // List all tables
    $sql2 = "SHOW TABLES";
    $result2 = $pdo->query($sql2);
    $allTables = $result2->fetchAll();
    echo "<h3>All Tables:</h3>";
    echo "<pre>";
    print_r($allTables);
    echo "</pre>";
    
    // Try to describe the expense_exp table if it exists
    if (!empty($tables)) {
        $sql3 = "DESCRIBE expense_exp";
        $result3 = $pdo->query($sql3);
        $columns = $result3->fetchAll();
        echo "<h3>expense_exp Columns:</h3>";
        echo "<pre>";
        print_r($columns);
        echo "</pre>";
    } else {
        echo "<p><strong>Table 'expense_exp' does not exist!</strong></p>";
    }
    
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
    echo "<br>";
    echo "<pre>" . $e->getTraceAsString() . "</pre>";
}
?>
