node_save

function node_save

node_save($node)

Saves changes to a node or adds a new node.

Parameters

$node: The $node object to be saved. If $node->nid is omitted (or $node->is_new is TRUE), a new node will be added.

File

modules/node/node.module, line 1077
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function node_save($node) {
  $transaction = db_transaction();

  try {
    // Load the stored entity, if any.
    if (!empty($node->nid) && !isset($node->original)) {
      $node->original = entity_load_unchanged('node', $node->nid);
    }

    field_attach_presave('node', $node);
    global $user;

    // Determine if