function DatabaseHandler::get_school_id_for_student_id

6.x DatabaseHandler.php DatabaseHandler::get_school_id_for_student_id($cwid)
7.x DatabaseHandler.php DatabaseHandler::get_school_id_for_student_id($cwid)

File

classes/DatabaseHandler.php, line 1027

Class

DatabaseHandler

Code

function get_school_id_for_student_id($cwid) {

  // Save to cache for quick lookup
  if (isset($GLOBALS ['cache_school_id_for_student_id'][$cwid])) {
    return $GLOBALS ['cache_school_id_for_student_id'][$cwid];
  }

  $rtn = intval(db_result(db_query("SELECT school_id FROM users WHERE cwid = ? AND is_student = 1", array($cwid))));
  $GLOBALS ['cache_school_id_for_student_id'][$cwid] = $rtn;

  return $rtn;
}