<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "<h1>Testing Database Connection Only</h1>";

try {
    // Include just the database configuration
    $host = 'localhost';
    $dbname = 'school_management';
    $username = 'root';
    $password = 'root';

    $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password, [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES => false,
        PDO::ATTR_TIMEOUT => 30
    ]);

    echo "<p style='color: green;'>✓ Database connection successful</p>";
    
    // Check specifically for the class_teachers table
    $stmt = $pdo->query("SHOW TABLES LIKE 'class_teachers'");
    $table_exists = $stmt->fetch();
    
    if ($table_exists) {
        echo "<p style='color: green;'>✓ class_teachers table exists in database</p>";
        
        // Count records
        $stmt = $pdo->query("SELECT COUNT(*) as count FROM class_teachers");
        $result = $stmt->fetch();
        echo "<p>Records in class_teachers table: " . $result['count'] . "</p>";
    } else {
        echo "<p style='color: red;'>❌ class_teachers table does not exist</p>";
    }
    
} catch (Exception $e) {
    echo "<p style='color: red;'>❌ Database error: " . $e->getMessage() . "</p>";
    echo "<p>File: " . $e->getFile() . " Line: " . $e->getLine() . "</p>";
}
?>