1 node.api.php | hook_node_update(Node $node) |
Respond to updates to a node.
This hook is invoked from node_save() after the database query that will update node in the node table is scheduled for execution, after the type-specific hook_update() is invoked, and after field_attach_update() is called.
Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_save() and db_transaction() for more info.
Parameters
Node $node: The node that is being updated.
Related topics
File
- core/
modules/ node/ node.api.php, line 666 - Hooks provided by the Node module.
Code
function hook_node_update(Node $node) {
db_update('mytable')
->fields(array('extra' => $node->extra))
->condition('nid', $node->nid)
->execute();
}