Esempio n. 1
0
 public static function updateInstructors($appointmentId, $oldInstructorsIds, $newInstructorsIds)
 {
     if (!isset($newInstructorsIds) || empty($newInstructorsIds)) {
         throw new Exception("Data have been malformed.");
     }
     Instructor::validateIds($newInstructorsIds);
     $update = false;
     $totInstructors = sizeof($newInstructorsIds);
     // check if there is a need to update data
     for ($i = 0; $i < $totInstructors; $i++) {
         $newInstructorId = $newInstructorsIds[$i];
         $oldInstructorId = $oldInstructorsIds[$i][AppointmentHasStudentFetcher::DB_COLUMN_INSTRUCTOR_ID];
         $studentId = $oldInstructorsIds[$i][AppointmentHasStudentFetcher::DB_COLUMN_STUDENT_ID];
         if (strcmp($newInstructorId, $oldInstructorId) !== 0) {
             AppointmentHasStudentFetcher::updateInstructorIdForStudentId($oldInstructorId, $studentId, $newInstructorId, $appointmentId);
             // need to retrieve new data
             $update = true;
         }
     }
     return $update;
 }