function nodeapi_example_node_insert

Implements hook_node_insert().

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

Related topics

1 call to nodeapi_example_node_insert()
nodeapi_example_node_update in nodeapi_example/nodeapi_example.module
Implements hook_node_update().

File

nodeapi_example/nodeapi_example.module, line 154

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();
    }
}