public static function deleteWithAppointmentId($appointmentId) { try { $reports = ReportFetcher::retrieveAllWithAppointmentId($appointmentId); $dbConnection = DatabaseManager::getConnection(); try { $dbConnection->beginTransaction(); $prevTransFromParent = false; } catch (PDOException $e) { $prevTransFromParent = true; } foreach ($reports as $report) { $reportId = $report[self::DB_COLUMN_ID]; ConclusionWrapUpFetcher::delete($reportId); StudentBroughtAlongFetcher::delete($reportId); PrimaryFocusOfConferenceFetcher::delete($reportId); AppointmentHasStudentFetcher::disconnectReport($reportId); self::delete($reportId); } AppointmentFetcher::updateLabel($appointmentId, Appointment::LABEL_MESSAGE_ADMIN_DISABLED, Appointment::LABEL_COLOR_CANCELED); if (!$prevTransFromParent) { $dbConnection->commit(); } return true; } catch (Exception $e) { if (isset($dbConnection)) { $dbConnection->rollback(); } throw new Exception($e->getMessage()); } return false; }