public static function insert($dateStart, $dateEnd, $courseId, $studentsIds, $tutorId, $instructorsIds, $termId)
 {
     date_default_timezone_set('Europe/Athens');
     $dateStart = $dateStart->format(Dates::DATE_FORMAT_IN);
     $dateEnd = $dateEnd->format(Dates::DATE_FORMAT_IN);
     try {
         $queryInsertUser = "******" . App::getDbName() . "`.`" . self::DB_TABLE . "` (`" . self::DB_COLUMN_START_TIME . "`,\t\t\t`" . self::DB_COLUMN_END_TIME . "`, `" . self::DB_COLUMN_COURSE_ID . "`, `" . self::DB_COLUMN_TUTOR_USER_ID . "`, `" . self::DB_COLUMN_TERM_ID . "`)\n\t\t\t\tVALUES(\n\t\t\t\t\t:start_time,\n\t\t\t\t\t:end_time,\n\t\t\t\t\t:course_id,\n\t\t\t\t\t:tutor_user_id,\n\t\t\t\t\t:term_id\n\t\t\t\t)";
         $dbConnection = DatabaseManager::getConnection();
         $dbConnection->beginTransaction();
         $queryInsertUser = $dbConnection->prepare($queryInsertUser);
         $queryInsertUser->bindParam(':start_time', $dateStart, PDO::PARAM_STR);
         $queryInsertUser->bindParam(':end_time', $dateEnd, PDO::PARAM_STR);
         $queryInsertUser->bindParam(':course_id', $courseId, PDO::PARAM_STR);
         $queryInsertUser->bindParam(':tutor_user_id', $tutorId, PDO::PARAM_STR);
         $queryInsertUser->bindParam(':term_id', $termId, PDO::PARAM_STR);
         $queryInsertUser->execute();
         // last inserted if of THIS connection
         $appointmentId = $dbConnection->lastInsertId();
         for ($i = 0; $i < sizeof($studentsIds); $i++) {
             AppointmentHasStudentFetcher::insert($appointmentId, $studentsIds[$i], $instructorsIds[$i]);
         }
         $dbConnection->commit();
         return $appointmentId;
     } catch (Exception $e) {
         if (isset($dbConnection)) {
             $dbConnection->rollback();
         }
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not insert data into database.");
     }
 }