<?php
// Upload this to: studytrack/api/check-push-table.php
// Then open: https://studytrack.edurx.icu/studytrack/api/check-push-table.php

require_once __DIR__ . '/../includes/config.php';
header('Content-Type: text/plain; charset=utf-8');

echo "=== push_subscriptions table structure ===\n\n";

try {
    $cols = $pdo->query("DESCRIBE push_subscriptions")->fetchAll(PDO::FETCH_ASSOC);
    foreach ($cols as $c) {
        echo $c['Field'] . " | " . $c['Type'] . "\n";
    }
} catch (Exception $e) {
    echo "ERROR: " . $e->getMessage() . "\n";
}

echo "\n=== Sample rows (first 3) ===\n";
try {
    $rows = $pdo->query("SELECT * FROM push_subscriptions LIMIT 3")->fetchAll(PDO::FETCH_ASSOC);
    if (empty($rows)) {
        echo "(empty — no subscriptions saved yet)\n";
    } else {
        foreach ($rows as $r) {
            print_r($r);
        }
    }
} catch (Exception $e) {
    echo "ERROR: " . $e->getMessage() . "\n";
}