fp_get_degree_major_code

5.x db.inc fp_get_degree_major_code($degree_id, $bool_reset_cache = FALSE)

Returns the major code for a given degree_id

3 calls to fp_get_degree_major_code()
system_flightpath_can_assign_course_to_degree_id in modules/system/system.module
Implements hook flightpath_can_assign_course_to_degree_id
_GroupList::sort_degree_advising_weight in classes/_GroupList.php
Sort this list of groups by the advising weights of the degrees they belong to.
_GroupList::z__sort_degree_advising_weight in classes/_GroupList.php

File

includes/db.inc, line 125
This file contains mostly db shortcuts.

Code

function fp_get_degree_major_code($degree_id, $bool_reset_cache = FALSE) {

  if ($bool_reset_cache) {
    unset($GLOBALS['fp_temp_degree_major_codes']);
  }

  // We will cache in a GLOBALS variable, to save lookup time.
  if (isset($GLOBALS['fp_temp_degree_major_codes'][$degree_id])) {
    return $GLOBALS['fp_temp_degree_major_codes'][$degree_id];
  }

  $res = db_query("SELECT major_code FROM degrees WHERE degree_id = ?", $degree_id);
  $cur = db_fetch_array($res);
  $major_code = trim($cur['major_code']);

  if ($major_code) {
    $GLOBALS['fp_temp_degree_major_codes'][$degree_id] = $major_code;
  }

  return $major_code;

}