public static function delete($appointmentId) { try { $dbConnection = DatabaseManager::getConnection(); try { $dbConnection->beginTransaction(); $prevTransFromParent = false; } catch (PDOException $e) { $prevTransFromParent = true; } ReportFetcher::deleteWithAppointmentId($appointmentId); AppointmentHasStudentFetcher::delete($appointmentId); $query = "DELETE FROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\t\tWHERE `" . self::DB_TABLE . "`.`" . self::DB_COLUMN_ID . "` = :appointment_id"; $query = $dbConnection->prepare($query); $query->bindParam(':appointment_id', $appointmentId, PDO::PARAM_INT); $query->execute(); if (!$prevTransFromParent) { $dbConnection->commit(); } return $query->rowCount(); } catch (Exception $e) { if (isset($dbConnection)) { $dbConnection->rollback(); } Mailer::sendDevelopers($e->getMessage(), __FILE__); throw new Exception("Could not delete appointment data." . $e->getMessage()); } return false; }