function DatabaseHandler::get_school_id_for_course_id

7.x DatabaseHandler.php DatabaseHandler::get_school_id_for_course_id($course_id, $bool_use_draft = FALSE)
6.x DatabaseHandler.php DatabaseHandler::get_school_id_for_course_id($course_id, $bool_use_draft = FALSE)
1 call to DatabaseHandler::get_school_id_for_course_id()

File

classes/DatabaseHandler.php, line 1047

Class

DatabaseHandler

Code

function get_school_id_for_course_id($course_id, $bool_use_draft = FALSE) {

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

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


  // Use GLOBALS cache to make this faster.
  if (isset($GLOBALS ['fp_school_id_for_course_id'][$table_name][$course_id])) {
    return $GLOBALS ['fp_school_id_for_course_id'][$table_name][$course_id];
  }

  $val = intval(db_result(db_query("SELECT school_id FROM $table_name WHERE course_id = ?", array($course_id))));

  $GLOBALS ['fp_school_id_for_course_id'][$table_name][$course_id] = $val;

  return $val;

}