function tripal_update_cvtermpath

2.x tripal_cv.api.inc tripal_update_cvtermpath($cv_id, $job_id = NULL)
3.x tripal_chado.module.DEPRECATED.api.inc tripal_update_cvtermpath($cv_id, $job_id = null)

Updates the cvtermpath table of Chado for the specified CV.

Parameters

$cv_id: The chado cv_id;

$job_id: This function is intended to be used with the Tripal Jobs API. When this function is called as a job the $job_id is automatically passed to this function.

Return value

TRUE on success FALSE on failure

Related topics

2 calls to tripal_update_cvtermpath()
tripal_cv_load_update_cvtermpath in tripal_cv/includes/tripal_cv.obo_loader.inc
A function for executing the cvtermpath function of Chado. This function populates the cvtermpath table of Chado for quick lookup of term relationships
tripal_cv_update_cvtermpath in tripal_cv/api/tripal_cv.DEPRECATED.inc
1 string reference to 'tripal_update_cvtermpath'

File

tripal_cv/api/tripal_cv.api.inc, line 305
This module provides a set of functions to simplify working with controlled vocabularies.

Code

function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
  // TODO: need better error checking in this function

  // first get the controlled vocabulary name:
  $sql = "SELECT * FROM {cv} WHERE cv_id = :cv_id";
  $cv = chado_query($sql, array(':cv_id' => $cv_id))->fetchObject();

  print "\nUpdating cvtermpath for $cv->name...\n";

  $previous = chado_set_active('chado');
  try {
    $sql = "SELECT * FROM fill_cvtermpath(:name)";
    db_query($sql, array(':name' => $cv->name));
    chado_set_active($previous);
  }
  catch (Exception $e) {
    chado_set_active($previous);
    $error = $e->getMessage();
    tripal_report_error('tripal_cv', TRIPAL_ERROR, "Could not fill cvtermpath table: @error", array('@error' => $error));
    return FALSE;
  }

  return TRUE;
}