function tripal_insert_dbxref

2.x tripal_db.api.inc tripal_insert_dbxref($values)
3.x tripal_chado.module.DEPRECATED.api.inc tripal_insert_dbxref($values)

Add a database reference

Parameters

$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/tripal_core.chado_nodes.dbxrefs.api.inc
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/tripal_db.api.inc
Add a record to a database reference linking table (ie: feature_dbxref)
tripal_db_add_dbxref in tripal_db/api/tripal_db.DEPRECATED.inc
tripal_insert_cvterm in tripal_cv/api/tripal_cv.api.inc
Add's a controlled vocabulary term to Chado.
1 string reference to 'tripal_insert_dbxref'

File

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

Code

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;
  }
}