function tripal_chado_add_cvterm_mapping
3.x tripal_chado.mapping.inc | tripal_chado_add_cvterm_mapping($cvterm_id, $tablename, $chado_field) |
4 calls to tripal_chado_add_cvterm_mapping()
- tripal_chado_map_cvterms in tripal_chado/
includes/ tripal_chado.mapping.inc - This function populates the Tripal entity tables using existing data in the database.
- tripal_chado_prepare_chado in tripal_chado/
includes/ setup/ tripal_chado.setup.inc - Prepares Chado for use by Tripal.
- tripal_chado_update_7306 in tripal_chado/
tripal_chado.install - Add cvterm mapping for the Map entity type
- tripal_chado_update_7307 in tripal_chado/
tripal_chado.install - Add cvterm mapping for the Publication entity type
File
- tripal_chado/
includes/ tripal_chado.mapping.inc, line 96
Code
function tripal_chado_add_cvterm_mapping($cvterm_id, $tablename, $chado_field) {
// check if the record exists
$record = db_select('chado_cvterm_mapping', 'tcm')
->fields('tcm', array('mapping_id'))
->condition('cvterm_id', $cvterm_id)
->execute()
->fetchField();
// insert records into the chado_cvterm_mapping table.
if (!$record) {
db_insert('chado_cvterm_mapping')
->fields(
array(
'cvterm_id' => $cvterm_id,
'chado_table' => $tablename,
'chado_field' => $chado_field
)
)
->execute();
}
// if the record exists, update the term mapping
else {
db_update('chado_cvterm_mapping')
->fields(
array(
'chado_table' => $tablename,
'chado_field' => $chado_field
)
)
->condition('cvterm_id', $cvterm_id)
->execute()
;
}
}