function tripal_cv_add_cv
2.x tripal_cv.DEPRECATED.inc | tripal_cv_add_cv($name, $definition) |
3.x tripal_cv.DEPRECATED.inc | tripal_cv_add_cv($name, $definition) |
1.x tripal_cv.api.inc | tripal_cv_add_cv($name, $definition) |
Adds a controlled vocabular to the CV table of Chado.
Parameters
$name: The name of the controlled vocabulary. These are typically all lower case with no special characters other than an undrescore (for spaces).
$comment: A description or definition of the vocabulary.
Return value
An object populated with fields from the newly added database.
Related topics
6 calls to tripal_cv_add_cv()
- tripal_analysis_add_cvterms in tripal_analysis/
tripal_analysis.install - tripal_analysis_update_6100 in tripal_analysis/
tripal_analysis.install - Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1 This update adds a new analysis_organism materialized view
- tripal_cv_add_cvterm in tripal_cv/
api/ tripal_cv.api.inc - Add's a CV term to the cvterm table. If the parent CV does not exist then that too is added to the CV table. If the cvterm is a relationship term then the $is_relationship argument should be set. The function will try to first find theā¦
- tripal_cv_load_obo_v1_2 in tripal_cv/
includes/ obo_loader.inc - tripal_cv_obo_add_cvterm_prop in tripal_cv/
includes/ obo_loader.inc - Add property to CVterm
File
- tripal_cv/
api/ tripal_cv.api.inc, line 399 - Controlled Vocabulary API
Code
function tripal_cv_add_cv($name, $definition) {
// insert/update values
$ins_values = array(
'name' => $name,
'definition' => $definition
);
// see if the CV (default-namespace) exists already in the database
$sel_values = array('name' => $name);
$sel_options = array('statement_name' => 'sel_cv_na');
$results = tripal_core_chado_select('cv', array('*'), $sel_values, $sel_options);
// if it does not exists then add it
if (count($results) == 0) {
$ins_options = array('statement_name' => 'ins_cv_nade');
$success = tripal_core_chado_insert('cv', $ins_values, $ins_options);
if (!$success) {
watchdog('tripal_cv', "Failed to create the CV record", NULL, WATCHDOG_WARNING);
return FALSE;
}
$results = tripal_core_chado_select('cv', array('*'), $sel_values, $sel_options);
}
// if it already exists then do an update
else {
$upd_options = array('statement_name' => 'upd_cv_nade');
$success = tripal_core_chado_update('cv', $sel_values, $ins_values, $upd_options);
if (!$success) {
watchdog('tripal_cv', "Failed to update the CV record", NULL, WATCHDOG_WARNING);
return FALSE;
}
$results = tripal_core_chado_select('cv', array('*'), $sel_values, $sel_options);
}
// return the cv object
return $results[0];
}