function DatabaseHandler::get_group_id

7.x DatabaseHandler.php DatabaseHandler::get_group_id($group_name, $catalog_year, $school_id = 0)
6.x DatabaseHandler.php DatabaseHandler::get_group_id($group_name, $catalog_year, $school_id = 0)

File

classes/DatabaseHandler.php, line 913

Class

DatabaseHandler

Code

function get_group_id($group_name, $catalog_year, $school_id = 0) {

  if ($catalog_year < variable_get_for_school("earliest_catalog_year", 2006, $school_id)) 
   {
    $catalog_year = variable_get_for_school("earliest_catalog_year", 2006, $school_id);
  }


  // If it's already in our static cache, just return that.
  static $group_id_cache = array();
  if (isset($group_id_cache [$group_name][$school_id][$catalog_year])) {
    return $group_id_cache [$group_name][$school_id][$catalog_year];
  }



  $res7 = $this->db_query("SELECT group_id FROM `groups`
              WHERE group_name = ?
              AND catalog_year = ?
              AND school_id = ?
              AND delete_flag = 0
               LIMIT 1 ", $group_name, $catalog_year, $school_id);
  if ($this->db_num_rows($res7) > 0) 
   {
    $cur7 = $this->db_fetch_array($res7);

    // Save to our cache
    $group_id_cache [$group_name][$school_id][$catalog_year] = $cur7 ['group_id'];
    return $cur7 ['group_id'];
  }
  return false;
}