Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

hook_insert

Definition

hook_insert($node)
documentation/hooks/node.php, line 282

Description

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_nodeapi() instead.

For a detailed usage example, see node_example.module.

Parameters

$node The node being inserted.

Return value

None.

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?php
function hook_insert($node) {
  db_query("INSERT INTO {mytable} (nid, extra)
    VALUES (%d, '%s')", $node->nid, $node->extra);
}
?>