<?php
include_once __DIR__ . '/config/database.php';

try {
    $db = new Database();
    $conn = $db->getConnection();
    
    // Check cards
    $stmt = $conn->query("SELECT * FROM cards");
    $cards = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo "Количество карт в БД: " . count($cards) . "\n";
    if (count($cards) > 0) {
        print_r($cards);
    }
    
    // Check accounts
    $stmt = $conn->query("SELECT * FROM accounts");
    $accounts = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo "\nКоличество счетов в БД: " . count($accounts) . "\n";
    
    // Check query used in API
    echo "\nПроверка API запроса (для admin, id=1):\n";
    $stmt = $conn->prepare("SELECT c.id, c.card_number, c.card_holder_name as card_holder, c.expiration_date as expiry_date, c.card_type as type, c.balance, c.status FROM cards c JOIN accounts a ON c.account_id = a.id WHERE a.user_id = ?");
    $stmt->execute([1]);
    $apiCards = $stmt->fetchAll(PDO::FETCH_ASSOC);
    print_r($apiCards);
    
} catch (Exception $e) {
    echo "Ошибка: " . $e->getMessage() . "\n";
}
?>
