You are here

function node_example_update in Examples for Developers 6

Implementation of hook_update().

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

Related topics

File

node_example/node_example.module, line 221
This is an example outlining how a module can be used to define a new node type.

Code

function node_example_update($node) {

  // if this is a new node or we're adding a new revision,
  if ($node->revision) {
    node_example_insert($node);
  }
  else {
    db_query("UPDATE {node_example} SET color = '%s', quantity = %d WHERE vid = %d", $node->color, $node->quantity, $node->vid);
  }
}