function tripal_get_cv
2.x tripal_cv.api.inc | tripal_get_cv($identifiers, $options = array()) |
3.x tripal_chado.module.DEPRECATED.api.inc | tripal_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 for 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
11 calls to tripal_get_cv()
- chado_organism_form in tripal_organism/
includes/ tripal_organism.chado_node.inc - Implement hook_form().
- chado_phylotree_form in tripal_phylogeny/
includes/ tripal_phylogeny.chado_node.inc - Implementation of hook_form().
- tripal_cv_admin_set_defaults_form in tripal_cv/
includes/ tripal_cv.admin.inc - tripal_cv_get_cv in tripal_cv/
api/ tripal_cv.DEPRECATED.inc - tripal_cv_get_cv_by_id in tripal_cv/
api/ tripal_cv.DEPRECATED.inc
4 string references to 'tripal_get_cv'
- tripal_cv_get_cv in tripal_cv/
api/ tripal_cv.DEPRECATED.inc - tripal_cv_get_cv_by_id in tripal_cv/
api/ tripal_cv.DEPRECATED.inc - tripal_cv_get_cv_by_name in tripal_cv/
api/ tripal_cv.DEPRECATED.inc - tripal_cv_get_cv_id in tripal_cv/
api/ tripal_cv.DEPRECATED.inc
File
- tripal_cv/
api/ tripal_cv.api.inc, line 47 - This module provides a set of functions to simplify working with controlled vocabularies.
Code
function tripal_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_cv_api',
TRIPAL_ERROR,
"tripal_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_cv_api',
TRIPAL_ERROR,
"tripal_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_cv_api',
TRIPAL_ERROR,
"tripal_get_cv: The identifiers you passed in were not unique. 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;
}
}