<?php
class ModelLocalisationZone extends Model {
	public function getZone($zone_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE zone_id = '" . (int)$zone_id . "' AND status = '1'");

		return $query->row;
	}

	public function getZonesByCountryId($country_id) {
		$zone_data = $this->cache->get('zone.' . (int)$country_id);

		if (!$zone_data) {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' AND status = '1' ORDER BY name");

			$zone_data = $query->rows;

			$this->cache->set('zone.' . (int)$country_id, $zone_data);
		}

		return $zone_data;
	}

    public function getCity($city_id)
    {
        $query = $this->db->query("SELECT * FROM ps_district WHERE district_id = '". (int)$city_id ."' ");
        return $query->row;
	}

    public function getCities($zone_id)
    {

		return $this->db->query("SELECT * FROM ps_district WHERE zone_id = '". (int)$zone_id ."' ")->rows;

		$citiy_data = $this->cache->get('city.' . (int)$zone_id);
		if(!$citiy_data){
			$query = $this->db->query("SELECT * FROM ps_district WHERE zone_id = '". (int)$zone_id ."' ");

			$citiy_data = $query->rows;
			$this->cache->set('city.' . (int)$zone_id, $citiy_data);
		}

		return $citiy_data;

        
        
	}
}