<?php
declare(strict_types=1);

require_once __DIR__ . "/../config/db.php";
require_once __DIR__ . "/../config/auth.php";


header('Content-Type: application/json; charset=utf-8');

try {
    $rows = $pdo->query("SELECT id, name FROM districts ORDER BY name ASC")->fetchAll();
    echo json_encode($rows, JSON_UNESCAPED_UNICODE);
} catch (Throwable $e) {
    http_response_code(500);
    echo json_encode(["error" => "districts_failed"]);
}
