function tripal_delete_mview

2.x tripal_core.mviews.api.inc tripal_delete_mview($mview_id)

Does the specified action for the specified Materialized View

Parameters

$op: The action to be taken. One of update or delete

$mview_id: The unique ID of the materialized view for the action to be performed on

Related topics

3 calls to tripal_delete_mview()
tripal_mviews_action in tripal_core/api/tripal_core.DEPRECATED.api.inc
tripal_mviews_delete_form_submit in tripal_core/includes/tripal_core.mviews.inc
form submit hook for the tripal_custom_tables_delete_form form.
tripal_phylogeny_uninstall in tripal_phylogeny/tripal_phylogeny.install
Implementation of hook_uninstall().
1 string reference to 'tripal_delete_mview'

File

tripal_core/api/tripal_core.mviews.api.inc, line 385
Provides an application programming interface (API) to manage materialized views in Chado.

Code

function tripal_delete_mview($mview_id) {
  global $user;

  if (!$mview_id) {
    return '';
  }

  // get this mview details
  $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id";
  $results = db_query($sql, array(':mview_id' => $mview_id));
  $mview = $results->fetchObject();

  // if op is to delete then do so
  // remove the mview from the tripal_mviews table
  $sql = "DELETE FROM {tripal_mviews} WHERE mview_id = $mview_id";
  db_query($sql);

  // does the table already exist?
  $mview_exists = chado_table_exists($mview->mv_table);

  // drop the table from chado if it exists
  if ($mview_exists) {
    $sql = "DROP TABLE {" . $mview->mv_table . "}";
    $success = chado_query($sql);
    if ($success) {
      drupal_set_message(t("Materialized view, %name, deleted.", array('%name' => $mview->name)));
    }
    else {
      drupal_set_message(t("Problem deleting materialized view, %name.", array('%name' => $mview->name)), 'error');
    }
  }
}