1 nodeapi_example.module nodeapi_example_node_insert($node)

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

modules/examples/nodeapi_example/nodeapi_example.module, line 167
Module implementation for nodeapi_example module.

Code

function nodeapi_example_node_insert($node) {
  if (config_get('nodeapi_example.settings', 'nodeapi_example_node_type_' . $node->type)) {
    // 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();
  }
}