function tripal_insert_dbxref

2.x tripal_insert_dbxref($values)

Add a database reference


$values: An associative array of the values to be inserted including:

  • db_id: the database_id of the database the reference is from
  • accession: the accession
  • version: (Optional) The version of the database reference
  • description: (Optional) A description of the database reference

Related topics

4 calls to tripal_insert_dbxref()
chado_update_node_form_dbxrefs in tripal_core/api/
This function is used in hook_insert or hook_update and handles inserting of any new dbxrefs and creation of links between those dbxrefs and node content
tripal_associate_dbxref in tripal_db/api/
Add a record to a database reference linking table (ie: feature_dbxref)
tripal_db_add_dbxref in tripal_db/api/
tripal_insert_cvterm in tripal_cv/api/
Add's a controlled vocabulary term to Chado.
1 string reference to 'tripal_insert_dbxref'


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


function tripal_insert_dbxref($values) {

  $db_id = $values['db_id'];
  $accession = $values['accession'];
  $version = (isset($values['version'])) ? $values['version'] : '';
  $description = (isset($values['description'])) ? $values['description'] : '';

  $ins_values = array(
    'db_id' => $db_id,
    'accession' => $accession,
    'version' => $version,
    'description' => $description

  // check to see if the dbxref exists
  $sel_values = array(
    'db_id' => $db_id,
    'accession' => $accession,
    'version' => $version
  $result = chado_select_record('dbxref', array('*'), $sel_values);

  // if it doesn't already exist then add it
  if (!$result) {
    $success = chado_insert_record('dbxref', $ins_values);
    if (!$success) {
      tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to insert the dbxref record $accession", NULL);
      return 0;
    $result = chado_select_record('dbxref', array('*'), $sel_values);

  if (isset($result[0])) {
    return $result[0];
  else {
    return FALSE;