hook_insert
- Versions
- 4.6 – 6
hook_insert($node)- 7
hook_insert(stdClass $node)
Respond to node insertion.
This is a hook used by node modules. It is called to allow the module to take action when a new node is being inserted in the database by, for example, inserting information into related tables.
To take action when nodes of any type are inserted (not just nodes of the type(s) defined by this module), use hook_node() instead.
For a detailed usage example, see node_example.module.
Parameters
$node The node being inserted.
Related topics
Code
modules/node/node.api.php, line 847
<?php
function hook_insert(stdClass $node) {
db_insert('mytable')
->fields(array(
'nid' => $node->nid,
'extra' => $node->extra,
))
->execute();
}
?>Login or register to post comments 