<?php

if ($this->is_id()) {
	//$delete_query = "DELETE FROM school_city WHERE scc_id = " . $this->get_id() . ";";
	//$sql->execute_query($delete_query);

	//akiknek ez a city_id van beállítva, azoknál null-ra állítjuk
	$school_city_query = "SELECT uk_id FROM user_kid WHERE uk_address_scc_id = " . $this->get_id();
	$school_city_assoc_array = $sql->assoc_array($school_city_query);
	foreach ($school_city_assoc_array as $uk_id) {
		$sql->update_table('user_kid', array('uk_address_scc_id' => 'null'), array('uk_id' => $uk_id['uk_id']));
	}

	//amelyik sulinak ez a city_id van beállítva, azoknál null-ra állítjuk
	$school_city_query = "SELECT sc_id FROM school WHERE sc_school_city_scc_id = " . $this->get_id();
	$school_city_assoc_array = $sql->assoc_array($school_city_query);
	foreach ($school_city_assoc_array as $sc_id) {
		$sql->update_table('school', array('sc_school_city_scc_id' => 'null'), array('sc_id' => $sc_id['sc_id']));
	}

	$sql->update_table('school_city', array('scc_deleted' => 1), array('scc_id' => $this->get_id()));

	log::register('delete_city', $this->get_id());
	header("Location: /admin/cities");
}


?>