You are here

function recipe_update in Recipe 7

Same name and namespace in other branches
  1. 5 recipe.module \recipe_update()
  2. 6 recipe.module \recipe_update()
  3. 7.2 recipe.module \recipe_update()

Implements hook_update().

As an existing node is being updated in the database, we need to do our own database updates.

File

./recipe.module, line 180
Contains functions for Recipe node CRUD and display.

Code

function recipe_update($node) {
  db_update('recipe')
    ->fields(array(
    'source' => $node->recipe_source,
    'yield' => $node->recipe_yield,
    'yield_unit' => $node->recipe_yield_unit,
    'description' => is_array($node->recipe_description) ? $node->recipe_description['value'] : $node->recipe_description,
    'instructions' => is_array($node->recipe_instructions) ? $node->recipe_instructions['value'] : $node->recipe_instructions,
    'notes' => is_array($node->recipe_notes) ? $node->recipe_notes['value'] : $node->recipe_notes,
    'preptime' => $node->recipe_preptime,
    'cooktime' => $node->recipe_cooktime,
  ))
    ->condition('nid', $node->nid)
    ->execute();
  recipe_save_ingredients($node);
}