Implements hook_node_insert().

As a new node is being inserted into the database, we need to do our own database inserts.

Related topics

File

nodeapi_example/nodeapi_example.module, line 154
Module implementation for nodeapi_example module.

Code

function nodeapi_example_node_insert($node) {
  if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {

    // Notice that we are ignoring any revision information using $node->nid
    db_insert('nodeapi_example')
      ->fields(array(
      'nid' => $node->nid,
      'vid' => $node->vid,
      'rating' => $node->nodeapi_example_rating,
    ))
      ->execute();
  }
}