<?php

    class Locality extends Core {

        function city() {

            $initials = $_GET['initials'];
            $sql = "SELECT a1.* FROM city as a1 LEFT JOIN states as a2 ON a2.id = a1.state WHERE initials = ?";
            $stmt = parent::$conn->prepare($sql);
            $stmt->execute([$initials]);           

            return $stmt->fetchAll(PDO::FETCH_ASSOC);

        }

        function district() {

            $city = $_GET['city'];
            $sql = "SELECT UPPER(district) FROM leads WHERE city = ? GROUP BY UPPER(district) ORDER BY district";
            $stmt = parent::$conn->prepare($sql);
            $stmt->execute([$city]);
            
            return $stmt->fetchAll(PDO::FETCH_ASSOC);

        }

    }