array( 'accession' => $accession, 'db_id' => array( 'name' => $dbname, ), ), 'featuremap_id' => $featuremap_id, ); $options = array('statement_name' => 'sel_featuremapdbxref_dbpu'); $results = tripal_core_chado_select('featuremap_dbxref', array('*'), $values, $options); // if the featuremap_dbxref record exist then we don't need to re-add it. if(count($results) > 0) { return $results[0]; } // make sure our database already exists $db = tripal_db_add_db($dbname); // get the database cross-reference $dbxvalues = array( 'accession' => $accession, 'db_id' => $db->db_id, ); $dbxoptions = array('statement_name' => 'sel_dbxref_acdb'); $results = tripal_core_chado_select('dbxref', array('dbxref_id'), $dbxvalues, $dbxoptions); // if the accession doesn't exist then add it if(count($results) == 0){ $dbxref = tripal_db_add_dbxref($db->db_id, $accession); } else { $dbxref = $results[0]; } // now add the record $options = array('statement_name' => 'ins_featuremapdbxref_dbpu'); $results = tripal_core_chado_insert('featuremap_dbxref', $values, $options); if (!$results) { watchdog('t_featuremap', "Cannot add map dbxref: %db:%accession.", array('%db' => $dbname, '%accession' => $accession). WATCHDOG_ERROR); return FALSE; } return $results; }