function DatabaseHandler::update_course_id

7.x DatabaseHandler.php DatabaseHandler::update_course_id($from_course_id, $to_course_id, $bool_draft = false)
6.x DatabaseHandler.php DatabaseHandler::update_course_id($from_course_id, $to_course_id, $bool_draft = false)

File

classes/DatabaseHandler.php, line 700

Class

DatabaseHandler

Code

function update_course_id($from_course_id, $to_course_id, $bool_draft = false) 
 {
  // This will convert *all* instances of "fromCourseID"
  // across every table that it is used, to toCourseID.
  // Use this function when you want to change a course's
  // course_id in the database.

  $table_array = array("advised_courses",
    "courses",
    "degree_requirements",
    "group_requirements",
    "student_unassign_group");

  if ($bool_draft) 
   { // only do the draft tables...
    $table_array = array(
      "draft_courses",
      "draft_degree_requirements",
      "draft_group_requirements",
    );
  }


  // Do the tables where it's named "course_id"...
  foreach ($table_array as $table_name) 
   {

    $res = $this->db_query("UPDATE $table_name
                SET course_id = '?'
                WHERE course_id = '?' ", $to_course_id, $from_course_id);
  }


  $res = $this->db_query("update student_substitutions
            set `required_course_id`='?'
            where `required_course_id`='?' ", $to_course_id, $from_course_id);

  $res = $this->db_query("update student_substitutions
            set `sub_course_id`='?'
            where `sub_course_id`='?' 
               and `sub_transfer_flag`='0' ", $to_course_id, $from_course_id);

  $res = $this->db_query("update transfer_eqv_per_student
            set `local_course_id`='?'
            where `local_course_id`='?' ", $to_course_id, $from_course_id);



}