function chado_get_record_entity_by_bundle

3.x tripal_chado.entity.api.inc chado_get_record_entity_by_bundle(TripalBundle $bundle, $record_id)

Retreive the entity_id assigned to a given record_id and bundle.

Parameters

$bundle: A bundle object (as retrieved from tripal_load_bundle_entity().

$record_id: The ID of the record in the Chado table. The record must belong to the table to which the bundle is associated in chado.

Return value

The ID of the entity that belongs to the given record_id.

Related topics

1 call to chado_get_record_entity_by_bundle()
so__transcript::load in tripal_chado/includes/TripalFields/so__transcript/so__transcript.inc

File

tripal_chado/api/tripal_chado.entity.api.inc, line 31
Provides an application programming interface (API) to manage entities that use Chado as their base data.

Code

function chado_get_record_entity_by_bundle(TripalBundle $bundle, $record_id) {
  if (!$bundle) {
    throw new Exception('Please provide a TripalBundle object.');
  }
  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 . '"');
  }

  $chado_entity_table = chado_get_bundle_entity_table($bundle);
  return db_select($chado_entity_table, 'CE')
    ->fields('CE', array('entity_id'))
    ->condition('CE.record_id', $record_id)
    ->execute()
    ->fetchField();
}