function chado_get_record_entity_by_table
3.x tripal_chado.entity.api.inc | chado_get_record_entity_by_table($data_table, $record_id) |
5 calls to chado_get_record_entity_by_table()
- chado_generate_var in tripal_chado/
api/ tripal_chado.variables.api.inc - Generates an object containing the full details of a record(s) in Chado.
- data__sequence_coordinates::load in tripal_chado/
includes/ TripalFields/ data__sequence_coordinates/ data__sequence_coordinates.inc - tripal_chado_pub_search_page in tripal_chado/
includes/ tripal_chado.pub_search.inc - The page that contains the publication search form and the results for the search
- tripal_feature_match_features_page in tripal_chado/
tripal_chado.module - Uses the value provided in the $id argument to find all features that match that ID by name, featurename or synonym. If it matches uniquenly to a single feature it will redirect to that feature page, otherwise, a list of matching features is shown.
- tripal_phylogeny_ajax_get_tree_json in tripal_chado/
includes/ tripal_chado.phylotree.inc - Get json representation of a phylotree id.
File
- tripal_chado/
api/ tripal_chado.entity.api.inc, line 67 - Provides an application programming interface (API) to manage entities that use Chado as their base data.
Code
function chado_get_record_entity_by_table($data_table, $record_id) {
// The data table and type_id are required.
if (!$data_table) {
throw new Exception('Please provide the $data_table argument.');
}
if (!$record_id) {
throw new Exception('Please provide an integer record ID.');
}
if (!is_numeric($record_id)) {
throw new Exception('Please provide an integer record ID. The value provided was "' . $record_id . '"');
}
// Get the list of bundles for this table.
$bundles = db_select('chado_bundle', 'CB')
->fields('CB', array('bundle_id'))
->condition('CB.data_table', $data_table)
->execute();
// Look for the record ID in the appropriate chado table.
while ($bundle_id = $bundles->fetchField()) {
$entity_id = db_select('chado_bio_data_' . $bundle_id, 'CBD')
->fields('CBD', array('entity_id'))
->condition('record_id', $record_id)
->execute()
->fetchField();
if ($entity_id) {
return $entity_id;
}
}
return NULL;
}