function tripal_db_add_dbxref

2.x tripal_db.DEPRECATED.inc tripal_db_add_dbxref($db_id, $accession, $version = '', $description = '')
3.x tripal_db.DEPRECATED.inc tripal_db_add_dbxref($db_id, $accession, $version = '', $description = '')
1.x tripal_db.api.inc tripal_db_add_dbxref($db_id, $accession, $version = '', $description = '')

Related topics

3 calls to tripal_db_add_dbxref()
tripal_cv_add_cvterm in tripal_cv/api/tripal_cv.api.inc
Add's a CV term to the cvterm table. If the parent CV does not exist then that too is added to the CV table. If the cvterm is a relationship term then the $is_relationship argument should be set. The function will try to first find theā€¦
tripal_featuremap_add_featuremap_dbxref in tripal_featuremap/api/tripal_featuremap.api.inc
tripal_pub_add_pub_dbxref in tripal_pub/api/tripal_pub.api.inc

File

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

Code

function tripal_db_add_dbxref($db_id, $accession, $version = '', $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,
  );
  $sel_options = array('statement_name' => 'sel_dbxref_dbacve', 'is_duplicate' => 1);
  $result = tripal_core_chado_select('dbxref', array('*'), $sel_values, $sel_options);

  // if it doesn't already exist then add it
  if (!$result) {
    $ins_options = array('statement_name' => 'ins_dbxref_dbacvede');
    $success = tripal_core_chado_insert('dbxref', $ins_values, $ins_options);
    if (!$success) {
      watchdog('tripal_cv', "Failed to insert the dbxref record $accession", NULL, WATCHDOG_WARNING);
      return 0;
    }
    $result = tripal_core_chado_select('dbxref', array('*'), $sel_values, $sel_options);
  }

  return $result[0];
}