Same name and namespace in other branches
- 4.7.x modules/taxonomy.module \taxonomy_node_save()
- 5.x modules/taxonomy/taxonomy.module \taxonomy_node_save()
- 6.x modules/taxonomy/taxonomy.module \taxonomy_node_save()
Save term associations for a given node.
File
- modules/
taxonomy.module, line 491 - Enables the organization of content into categories.
Code
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);
}
}
}
}
}