<?php
require_once 'config.php';
session_start();

$pdo = getDBConnection();
if (!$pdo)
    die("No connection");

header('Content-Type: text/plain');

echo "--- SHIPS ---\n";
$stmt = $pdo->query("SELECT ship_id, name, type FROM ships");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));

echo "\n--- USERS ---\n";
$stmt = $pdo->query("SELECT id, username, role, ship_id FROM users");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));

echo "\n--- USER_SHIPS ---\n";
$stmt = $pdo->query("SELECT * FROM user_ships");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));

echo "\n--- SENSOR_POSITIONS COUNT per Ship ---\n";
$stmt = $pdo->query("SELECT buque_id, COUNT(*) as count FROM sensor_positions GROUP BY buque_id");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));

echo "\n--- YOUR SESSION ---\n";
print_r($_SESSION);
?>