taxonomy_node_save

Versions
4.6 – 5
taxonomy_node_save($nid, $terms)
6
taxonomy_node_save($node, $terms)

Save term associations for a given node.

Code

modules/taxonomy.module, line 491

<?php
function taxonomy_node_save($nid, $terms) {
  taxonomy_node_delete($nid);

  if (is_array($terms)) {
    foreach ($terms as $term) {
      if (is_array($term)) {
        foreach ($term as $tid) {
          if ($tid) {
            db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $tid);
          }
        }
      }
      else if ($term) {
        db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term);
      }
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.