function drush_tripal_core_tripal_update_mview

2.x tripal_core.drush.inc drush_tripal_core_tripal_update_mview()
3.x tripal_core.drush.inc drush_tripal_core_tripal_update_mview()
1.x tripal_core.drush.inc drush_tripal_core_tripal_update_mview()

Updates the specified materialized view

Parameters

$mview_id: The ID of the materialized view (tripal_mview.mview_id)

$table_name: The name of the table storing the materialized view (tripal_mview.mv_table)

Note: Either $mview_id OR $table_name is required

File

tripal_core/tripal_core.drush.inc, line 252
Contains function relating to drush-integration of this module.

Code

function drush_tripal_core_tripal_update_mview() {
  $mview_id = drush_get_option('mview_id');
  $table_name = drush_get_option('table_name');

  // Either table_name or mview is required
  if (!$mview_id) {
    if ($table_name) {
      // if table_name supplied use that to get mview_id
      $sql = "SELECT mview_id FROM {tripal_mviews} WHERE mv_table='%s'";
      $r = db_fetch_object(db_query($sql, $table_name));
      if (!$r->mview_id) {
        drush_set_error('No Materialized View associated with that table_name.');
      }
      $mview_id = $r->mview_id;
    }
    else {
      drush_set_error('Either mview_id OR table_name are required.');
    }
  }

  drush_print('Updating the Materialized View with ID=' . $mview_id);
  $status = tripal_update_mview($mview_id);
  if ($status) {
    drush_log('Materialized View Updated', 'ok');
  }
  else {
    drush_set_error('Update failed.');
  }
}