function hook_insert
7.x node.api.php | hook_insert($node) |
6.x node.php | hook_insert($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.
Parameters
$node: The node being inserted.
Return value
None.
To take action when nodes of any type are inserted (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.
For a detailed usage example, see node_example.module.
Related topics
2 functions implement hook_insert()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- poll_insert in drupal-6.x/
modules/ poll/ poll.module - Implementation of hook_insert().
- search_query_insert in drupal-6.x/
modules/ search/ search.module - Return a query with the given module-specific search option inserted in. e.g. 'type:book'.
3 invocations of hook_insert()
- node_type_save in drupal-6.x/
modules/ node/ node.module - Saves a node type to the database.
- taxonomy_save_vocabulary in drupal-6.x/
modules/ taxonomy/ taxonomy.module - user_save in drupal-6.x/
modules/ user/ user.module - Save changes to a user account or add a new user.
File
- documentation-6.x/
developer/ hooks/ node.php, line 295 - These hooks are defined by node modules, modules that define a new kind of node.
Code
function hook_insert($node) {
db_query("INSERT INTO {mytable} (nid, extra)
VALUES (%d, '%s')", $node->nid, $node->extra);
}