function hook_insert
7.x node.api.php | hook_insert($node) |
6.x node.php | hook_insert($node) |
Respond to creation of a new node.
This hook is invoked only on the module that defines the node's content type (use hook_node_insert() to act on all node insertions).
This hook is invoked from node_save() after the node is inserted into the node table in the database, before field_attach_insert() is called, and before hook_node_insert() is invoked.
Parameters
$node: The node that is being created.
Related topics
43 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.
- ajax_command_insert in drupal-7.x/
includes/ ajax.inc - Creates a Drupal Ajax 'insert' command using the method in #ajax['method'].
- book_node_insert in drupal-7.x/
modules/ book/ book.module - Implements hook_node_insert().
- comment_node_insert in drupal-7.x/
modules/ comment/ comment.module - Implements hook_node_insert().
- comment_node_type_insert in drupal-7.x/
modules/ comment/ comment.module - Implements hook_node_type_insert().
- db_insert in drupal-7.x/
includes/ database/ database.inc - Returns a new InsertQuery object for the active database.
2 invocations of hook_insert()
- field_attach_insert in drupal-7.x/
modules/ field/ field.attach.inc - Save field data for a new entity.
- user_save in drupal-7.x/
modules/ user/ user.module - Save changes to a user account or add a new user.
File
- drupal-7.x/
modules/ node/ node.api.php, line 1161 - Hooks provided by the Node module.
Code
function hook_insert($node) {
db_insert('mytable')
->fields(array(
'nid' => $node->nid,
'extra' => $node->extra,
))
->execute();
}