public function update() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { echo '0'; return; } $id = (int) $_POST['id']; $name = remove_slashes($_POST['name']); $cityDAO = new CityDAO(DataSource::getInstance()); $cityDAO->update($id, $name); echo '1'; }