function chado_insert_dbxref
3.x tripal_chado.db.api.inc | chado_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.
Return value
The newly inserted dbxref as an object, similar to that returned by the chado_select_record() function.
Related topics
6 calls to chado_insert_dbxref()
- chado_associate_dbxref in tripal_chado/
api/ modules/ tripal_chado.db.api.inc - Add a record to a database reference linking table (ie: feature_dbxref).
- chado_insert_cvterm in tripal_chado/
api/ modules/ tripal_chado.cv.api.inc - Add's a controlled vocabulary term to Chado.
- data__accession_widget::submit in tripal_chado/
includes/ TripalFields/ data__accession/ data__accession_widget.inc - TaxonomyImporter::addDbxref in tripal_chado/
includes/ TripalImporter/ TaxonomyImporter.inc - tripal_insert_dbxref in tripal_chado/
api/ modules/ tripal_chado.module.DEPRECATED.api.inc - Add a database reference.
File
- tripal_chado/
api/ modules/ tripal_chado.db.api.inc, line 418 - Provides API functions specificially for managing external database reference records in Chado.
Code
function chado_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_chado', 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;
}
}