function chado_get_cv
3.x tripal_chado.cv.api.inc | chado_get_cv($identifiers, $options = array()) |
Retrieves a chado controlled vocabulary variable
Parameters
$identifier: An array with the key stating what the identifier is. Supported keys (only on of the following unique keys is required):
- cv_id: the chado cv.cv_id primary key.
- name: the chado cv.name field (assume unique).
$options: An array of options. Supported keys include:
- Any keys supported by chado_generate_var(). See that function definition fot additional details.
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the cv record to be returned.
Return value
If unique values were passed in as an identifier then an object describing the cv will be returned (will be a chado variable from chado_generate_var()). Otherwise, FALSE will be returned.
Related topics
12 calls to chado_get_cv()
- chado_insert_cvterm in tripal_chado/
api/ modules/ tripal_chado.cv.api.inc - Add's a controlled vocabulary term to Chado.
- NewickImporter::form in tripal_chado/
includes/ TripalImporter/ NewickImporter.inc - sbo__relationship::instanceSettingsFormValidate in tripal_chado/
includes/ TripalFields/ sbo__relationship/ sbo__relationship.inc - _state
- sbo__relationship_widget::form in tripal_chado/
includes/ TripalFields/ sbo__relationship/ sbo__relationship_widget.inc - schema__additional_type_widget::form in tripal_chado/
includes/ TripalFields/ schema__additional_type/ schema__additional_type_widget.inc
File
- tripal_chado/
api/ modules/ tripal_chado.cv.api.inc, line 47 - Provides API functions specificially for managing controlled vocabulary records in Chado.
Code
function chado_get_cv($identifiers, $options = array()) {
// Set Defaults.
if (!isset($options['include_fk'])) {
// Tells chado_generate_var not to follow any foreign keys.
$options['include_fk'] = array();
}
// Error Checking of parameters.
if (!is_array($identifiers)) {
tripal_report_error(
'tripal_chado_api',
TRIPAL_ERROR,
"chado_get_cv: The identifier passed in is expected to be an array with the key
matching a column name in the cv table (ie: cv_id or name). You passed in %identifier.",
array(
'%identifier' => print_r($identifiers, TRUE)
)
);
}
elseif (empty($identifiers)) {
tripal_report_error(
'tripal_chado_api',
TRIPAL_ERROR,
"chado_get_cv: You did not pass in anything to identify the cv you want. The identifier
is expected to be an array with the key matching a column name in the cv table
(ie: cv_id or name). You passed in %identifier.",
array(
'%identifier' => print_r($identifiers, TRUE)
)
);
}
// Try to get the cv.
$cv = chado_generate_var(
'cv',
$identifiers,
$options
);
// Ensure the cv is singular. If it's an array then it is not singular.
if (is_array($cv)) {
tripal_report_error(
'tripal_chado_api',
TRIPAL_ERROR,
"chado_get_cv: The identifiers you passed in were not unique. You passed in %identifier.",
array(
'%identifier' => print_r($identifiers, TRUE)
)
);
}
// Report an error if $cv is FALSE since then chado_generate_var has failed.
elseif ($cv === FALSE) {
tripal_report_error(
'tripal_chado_api',
TRIPAL_ERROR,
"chado_get_cv: chado_generate_var() failed to return a cv based on the identifiers
you passed in. You should check that your identifiers are correct, as well as, look
for a chado_generate_var error for additional clues. You passed in %identifier.",
array(
'%identifier' => print_r($identifiers, TRUE)
)
);
}
// Else, as far we know, everything is fine so give them their cv :)
else {
return $cv;
}
}