function tripal_db_get_dbxref

2.x tripal_db.DEPRECATED.inc tripal_db_get_dbxref($select_values)
3.x tripal_db.DEPRECATED.inc tripal_db_get_dbxref($select_values)
1.x tripal_db.api.inc tripal_db_get_dbxref($select_values)

Purpose: To retrieve a chado database reference object

   $select_values = array(
     'accession' => 'synonym',
     'db_id' => array(
       'name' => 'SOFP'
     )
   );
   $dbxref_object = tripal_db_get_dbxref($select_values);

The above code selects the synonym database reference and returns the following object:

   $dbxref_object = stdClass Object (
     [dbxref_id] => 2581
     [accession] => synonym
     [description] =>
     [version] =>
     [db_db_id] => 49
     [db_name] => SOFP
     [db_description] =>
     [db_urlprefix] =>
     [db_url] =>
   );

Parameters

$select_values: An array meant to uniquely select a given database reference

Return value

Chado database reference object

The database reference is selected using tripal_core_chado select and as such the $select_values array parameter meant to uniquely identify the database reference to be returned follows the same form as when using tripal_core_chado_select directly.

Example Usage:

Related topics

1 call to tripal_db_get_dbxref()

File

tripal_db/api/tripal_db.api.inc, line 211
Provides an application programming interface (API) to manage references to external databases

Code

function tripal_db_get_dbxref($select_values) {

  $columns = array(
    'dbxref_id',
    'db_id',
    'accession',
    'description',
    'version'
  );
  $results = tripal_core_chado_select('dbxref', $columns, $select_values);
  if (sizeof($results) == 1) {
    $dbxref = tripal_db_add_db_to_object(array('db_id' => $results[0]->db_id), $results[0], array());
    unset($dbxref->db_id);

    return $dbxref;
  }
  elseif (empty($results)) {
    watchdog('tripal_db', 
    'tripal_db_get_dbxref: No dbxref matches criteria values:%values', 
    array('%values' => print_r($select_values, TRUE)), 
    WATCHDOG_WARNING
    );
    return FALSE;
  }
  else {
    watchdog('tripal_db', 
    'tripal_db_get_dbxref: 2+ dbxrefs match criteria values:%values', 
    array('%values' => print_r($select_values, TRUE)), 
    WATCHDOG_WARNING
    );
  }

}