function tripal_get_default_cv

2.x tripal_cv.api.inc tripal_get_default_cv($table, $field)
3.x tripal_cv.api.inc tripal_get_default_cv($table, $field)

Retrieves the default vocabulary for a given table and field.

Each table in Chado that has a 'type_id' (or foreign key constraint to the cvterm table) will have a default vocabulary assigned. This indicates to Tripal that terms in that vocabulary are used to set the type_id for that table. An example where this is used is the tripal_get_cvterm_select_options() function which generates a list of options for a select box used in a Drupal form. The select box will list the terms from the default vocabulary in the drop down.

This function uses the Chado table and field name (e.g. 'type_id') to retreive the vocabulary assgined.

Parameters

$table: The name of the table that contains a field with a foreign key relationship to the cvterm table

$field: The table field name that has the foreign key relationship to the cvterm table for which the default vocabulary will be set

Return value

The cv object of the default vocabulary or an empty array if not available.

Related topics

14 calls to tripal_get_default_cv()
chado_add_node_form_properties in legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc
chado_add_node_form_relationships in legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
Provides a form for adding to BASE_relationship and relationship tables
chado_analysis_form in legacy/tripal_analysis/includes/tripal_analysis.chado_node.inc
Implements hook_form(). When editing or creating a new node of type 'chado_analysis' we need a form. This function creates the form that will be used for this.
chado_contact_form in legacy/tripal_contact/includes/tripal_contact.chado_node.inc
Implementation of hook_form().
chado_featuremap_form in legacy/tripal_featuremap/includes/tripal_featuremap.chado_node.inc
When editing or creating a new node of type 'chado_featuremap' we need a form. This function creates the form that will be used for this.

... See full list

File

legacy/tripal_cv/api/tripal_cv.api.inc, line 45
Provides legacy application programming interface (API) to manage controlled vocabularies in the Chado database.

Code

function tripal_get_default_cv($table, $field) {
  $sql = "
    SELECT cv_id
    FROM {tripal_cv_defaults}
    WHERE table_name = :table and field_name = :field
  ";
  $cv_id = db_query($sql, array(':table' => $table, ':field' => $field))->fetchField();

  return tripal_get_cv(array('cv_id' => $cv_id));
}