function chado_library_delete

2.x tripal_library.chado_node.inc chado_library_delete(&$node)
3.x tripal_library.chado_node.inc chado_library_delete(&$node)
1.x tripal_library.module chado_library_delete(&$node)

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

Related topics

File

tripal_library/tripal_library.module, line 680

Code

function chado_library_delete(&$node) {

  $library_id = chado_get_id_for_node('library', $node);

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

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

  // Remove data from library and libraryprop tables of chado database as well
  chado_query("DELETE FROM {libraryprop} WHERE library_id = %d", $library_id);
  chado_query("DELETE FROM {library} WHERE library_id = %d", $library_id);
}