function chado_get_id_from_nid

2.x tripal_core.chado_nodes.api.inc chado_get_id_from_nid($table, $nid, $linking_table = NULL)

Get chado id for a node. E.g, if you want to get 'analysis_id' from the 'analysis' table for a synced 'chado_analysis' node, (the same for organisms and features): $analysis_id = chado_get_id_from_nid ('analysis', $node->nid) $organism_id = chado_get_id_from_nid ('organism', $node->nid) $feature_id = chado_get_id_from_nid ('feature', $node->nid)

Parameters

$table: The chado table the chado record is from

$nid: The value of the primary key of node

$linking_table: The Drupal table linking the chado record to it's node. This field is optional and defaults to chado_$table

Return value

The chado id of the associated chado record

Related topics

57 calls to chado_get_id_from_nid()
chado_analysis_delete in tripal_analysis/includes/tripal_analysis.chado_node.inc
Implements hook_delete(). Removes analysis from the chado database.
chado_analysis_insert in tripal_analysis/includes/tripal_analysis.chado_node.inc
Implements hook_insert(). When a new chado_analysis node is created we also need to add information to our chado_analysis table. This function is called on insert of a new node of type 'chado_analysis' and inserts the necessary information.
chado_analysis_load in tripal_analysis/includes/tripal_analysis.chado_node.inc
Implements hook_load(). When a node is requested by the user this function is called to allow us to add auxiliary data to the node object.
chado_analysis_update in tripal_analysis/includes/tripal_analysis.chado_node.inc
Implements hook_update(). Update analyses
chado_contact_delete in tripal_contact/includes/tripal_contact.chado_node.inc
Implements hook_delete().

... See full list

1 string reference to 'chado_get_id_from_nid'

File

tripal_core/api/tripal_core.chado_nodes.api.inc, line 57
API to handle much of the common functionality implemented when creating a drupal node type.

Code

function chado_get_id_from_nid($table, $nid, $linking_table = NULL) {
  if (empty($linking_table)) {
    $linking_table = 'chado_' . $table;
  }

  $sql = "SELECT " . $table . "_id as id FROM {$linking_table} WHERE nid = :nid";
  return db_query($sql, array(':nid' => $nid))->fetchField();
}