function chado_featuremap_delete

2.x tripal_featuremap.chado_node.inc chado_featuremap_delete(&$node)
3.x tripal_featuremap.chado_node.inc chado_featuremap_delete(&$node)
1.x tripal_featuremap.module chado_featuremap_delete(&$node)

Delete data from drupal and chado databases when a node is deleted

Related topics

File

tripal_featuremap/tripal_featuremap.module, line 604

Code

function chado_featuremap_delete(&$node) {

  $featuremap_id = chado_get_id_for_node('featuremap', $node);

  // if we don't have a map id for this node then this isn't a node of
  // type chado_featuremap or the entry in the chado_featuremap table was lost.
  if (!$featuremap_id) {
    return;
  }

  // Remove data from {chado_featuremap}, {node} and {node_revisions} tables of
  // drupal database
  $sql_del = "DELETE FROM {chado_featuremap} " .
    "WHERE nid = %d " .
    "AND vid = %d";
  db_query($sql_del, $node->nid, $node->vid);
  $sql_del = "DELETE FROM {node} " .
    "WHERE nid = %d " .
    "AND vid = %d";
  db_query($sql_del, $node->nid, $node->vid);
  $sql_del = "DELETE FROM {node_revisions} " .
    "WHERE nid = %d " .
    "AND vid = %d";
  db_query($sql_del, $node->nid, $node->vid);

  // Remove data from map and mapprop tables of chado database as well
  chado_query("DELETE FROM {featuremap} WHERE featuremap_id = %d", $featuremap_id);
  chado_query("DELETE FROM {featuremapprop} WHERE featuremap_id = %d", $featuremap_id);
}