_DatabaseHandler::get_course_id

5.x _DatabaseHandler.php _DatabaseHandler::get_course_id($subject_id, $course_num, $catalog_year = "", $bool_use_draft = false)
4.x _DatabaseHandler.php _DatabaseHandler::get_course_id($subject_id, $course_num, $catalog_year = "", $bool_use_draft = false)

File

classes/_DatabaseHandler.php, line 1250

Class

_DatabaseHandler

Code

function get_course_id($subject_id, $course_num, $catalog_year = "", $bool_use_draft = false) {
  // Ignore the colon, if there is one.
  if (strpos($course_num, ":")) {
    //$course_num = substr($course_num,0,-2);
    $temp = explode(":", $course_num);
    $course_num = trim($temp[0]);
  }


  // Always override if the global variable is set.
  if (@$GLOBALS["fp_advising"]["bool_use_draft"] == true) {
    $bool_use_draft = true;
  }


  $catalog_line = "";

  if ($catalog_year != "") {
    $catalog_line = "and `catalog_year`='$catalog_year' ";
  }

  $table_name = "courses";
  if ($bool_use_draft) {
    $table_name = "draft_$table_name";
  }

  $res7 = $this->db_query("SELECT course_id FROM $table_name
              WHERE subject_id = ?
              AND course_num = ?
              $catalog_line
               ORDER BY catalog_year DESC LIMIT 1 ", $subject_id, $course_num);
  if ($this->db_num_rows($res7) > 0) {
    $cur7 = $this->db_fetch_array($res7);
    return $cur7["course_id"];
  }
  return FALSE;
}