hook_update

Versions
4.6 – 7
hook_update($node)

Respond to node updating.

This is a hook used by node modules. It is called to allow the module to take action when an edited node is being updated in the database by, for example, updating information in related tables.

To take action when nodes of any type are updated (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.

For a detailed usage example, see node_example.module.

Parameters

$node The node being updated.

Return value

None.

Related topics

Code

developer/hooks/node.php, line 349

<?php
function hook_update($node) {
  db_query("UPDATE {mytable} SET extra = '%s' WHERE nid = %d",
    $node->extra, $node->nid);
}
?>

I know it says this for

nvahalik - Fri, 2009-10-30 20:38

I know it says this for hook_install, but it is missing here. If you have a module that you are developing and you start adding these, you need to whatever you put in your update hook into your hook_install as well. When installing a module, it does not execute each of these. It simply finds the highest number and sets that as the version. Hopefully this will save you some time and frustration.

Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.