You are here

function recipe_load_ingredients in Recipe 5

Same name and namespace in other branches
  1. 6 recipe.module \recipe_load_ingredients()
  2. 7 recipe.module \recipe_load_ingredients()

Loads the ingredients for a recipe

2 calls to recipe_load_ingredients()
recipe_load in ./recipe.module
Implementation of hook_load().
recipe_save_ingredients in ./recipe.module
Saves the changed ingredients of a recipe node to the database (by comparing the old and new ingredients first)

File

./recipe.module, line 772
recipe.module - share recipes for drupal 5.x

Code

function recipe_load_ingredients($node) {
  $rs = db_query('
  SELECT
    ri.id,
    i.name,
    i.link,
    ri.quantity,
    ri.unit_id,
    u.abbreviation,
    ri.ingredient_id
  FROM
    {recipe_node_ingredient} ri,
    {recipe_ingredient} i,
    {recipe_unit} u
  WHERE
    ri.ingredient_id = i.id
    AND ri.unit_id = u.id
    AND ri.nid=%d
  ORDER BY
	ri.id', $node->nid);
  $ingredients = array();
  while ($ingredient = db_fetch_object($rs)) {
    $ingredients[] = $ingredient;
  }
  return $ingredients;
}