function recipe_load_ingredients in Recipe 7
Same name and namespace in other branches
- 5 recipe.module \recipe_load_ingredients()
- 6 recipe.module \recipe_load_ingredients()
Loads the ingredients for a recipe.
1 call to recipe_load_ingredients()
- recipe_load in ./
recipe.module - Implements hook_load().
File
- ./
recipe.module, line 1244 - Contains functions for Recipe node CRUD and display.
Code
function recipe_load_ingredients($nid) {
$select = db_select('recipe_node_ingredient', 'ri');
$select
->join('recipe_ingredient', 'i', 'ri.ingredient_id = i.id');
$select
->addField('ri', 'id', 'ri_id');
$select
->addField('i', 'name');
$select
->addField('ri', 'note');
$select
->addField('i', 'link');
$select
->addField('ri', 'quantity');
$select
->addField('ri', 'unit_key');
$select
->addField('ri', 'weight');
$select
->addField('ri', 'ingredient_id');
$select
->condition('ri.nid', $nid);
$select
->orderBy('ri.weight', 'ASC');
$ingredients = array();
$result = $select
->execute()
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $record) {
$ingredients[] = $record;
}
return $ingredients;
}