<?php
header('Content-Type: text/plain; charset=utf-8');

$host = '127.0.0.1';
$dbname = 'sademlis_Ostad51';
$user = 'root';
$pass = '';

try {
    $pdo = new PDO(
        "mysql:host=$host;dbname=$dbname;charset=utf8mb4",
        $user,
        $pass,
        [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        ]
    );

    echo "Database connection successful\n";
    echo "Server time: " . date('Y-m-d H:i:s') . "\n";
    echo "Database: " . $dbname . "\n";

    $stmt = $pdo->query("SHOW TABLES");
    $tables = $stmt->fetchAll(PDO::FETCH_COLUMN);

    echo "\nTables:\n";
    if ($tables) {
        foreach ($tables as $table) {
            echo "- " . $table . "\n";
        }
    } else {
        echo "No tables found.\n";
    }
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage() . "\n";
}
