tripal_chado.api.inc 624 B

1234567891011121314151617181920212223
  1. <?php
  2. /**
  3. * Retrieves an entity that matches the given table and record id.
  4. *
  5. * @param $table
  6. * The name of the Chado table.
  7. * @param $record_id
  8. * The record's primary key in the table specified by $table.
  9. */
  10. function tripal_load_chado_entity($table, $record_id) {
  11. $entity_id = db_select('chado_entity', 'ce')
  12. ->fields('ce', array('entity_id'))
  13. ->condition('ce.record_id', $record_id)
  14. ->condition('ce.data_table', $table)
  15. ->execute()
  16. ->fetchField();
  17. if ($entity_id) {
  18. $entity = entity_load('TripalEntity', array($entity_id));
  19. return reset($entity);
  20. }
  21. return NULL;
  22. }