function chado_get_nid_from_id

2.x tripal_core.chado_nodes.api.inc chado_get_nid_from_id($table, $id, $linking_table = NULL)
3.x tripal_core.chado_nodes.api.inc chado_get_nid_from_id($table, $id, $linking_table = NULL)

Get node id for a chado feature/organism/analysis. E.g, if you want to get the node id for an analysis, use: $nid = chado_get_nid_from_id ('analysis', $analysis_id) Likewise, $nid = chado_get_nid_from_id ('organism', $organism_id) $nid = chado_get_nid_from_id ('feature', $feature_id)

Parameters

$table: The chado table the id is from

$id: The value of the primary key from the $table chado table (ie: feature_id)

$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 nid of the associated node

Related topics

6 calls to chado_get_nid_from_id()
chado_expand_var in tripal_core/api/tripal_core.chado_variables.api.inc
Retrieves fields, or tables that were excluded by default from a variable.
chado_get_node_id in tripal_core/api/tripal_core.DEPRECATED.api.inc
drush_tripal_phylogeny_trp_insert_phylotree in tripal_phylogeny/tripal_phylogeny.drush.inc
Deletes a phylotree record.
drush_tripal_phylogeny_trp_update_phylotree in tripal_phylogeny/tripal_phylogeny.drush.inc
tripal_feature_load_featurelocs in tripal_feature/theme/tripal_feature.theme.inc
Load the locations for a given feature

... See full list

1 string reference to 'chado_get_nid_from_id'

File

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

Code

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

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