You are here

function recipe_unit_abbreviation in Recipe 6

Same name and namespace in other branches
  1. 5 recipe.module \recipe_unit_abbreviation()

Converts a recipe unit ID to it's abbreviation

1 call to recipe_unit_abbreviation()
theme_recipe_ingredients in ./recipe.module

File

./recipe.module, line 1133
recipe.module - share recipes

Code

function recipe_unit_abbreviation($unit_id) {
  static $abbreviations;
  if (!$abbreviations) {
    $rs = db_query("SELECT id, abbreviation FROM {recipe_unit}");
    while ($unit = db_fetch_object($rs)) {
      $abbreviations[$unit->id] = $unit->abbreviation;
    }
  }
  return $abbreviations[$unit_id];
}