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)

Implements hook_delete().

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

Related topics

File

tripal_featuremap/includes/tripal_featuremap.chado_node.inc, line 449
Hooks implementing the feature map node content type

Code

function chado_featuremap_delete(&$node) {

  $featuremap_id = chado_get_id_from_nid('featuremap', $node->nid);

  // 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 = :nid AND vid = :vid";
  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));

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

}