function tripal_stock_get_stock_by_stock_id

2.x tripal_stock.DEPRECATED.inc tripal_stock_get_stock_by_stock_id($stock_id)
3.x tripal_stock.DEPRECATED.inc tripal_stock_get_stock_by_stock_id($stock_id)
1.x tripal_stock.api.inc tripal_stock_get_stock_by_stock_id($stock_id)

Purpose: Return a given stock object using the stock id

Return value

Stock object created by node load

Related topics

3 calls to tripal_stock_get_stock_by_stock_id()
tripal_stock_get_stocks in tripal_stock/api/tripal_stock.api.inc
Purpose: Return all stocks that match a given criteria
tripal_stock_get_stocks_by_stockprop in tripal_stock/api/tripal_stock.api.inc
Purpose: Retrieve stocks based on associated stock properties
tripal_stock_get_stock_by_name_identifier in tripal_stock/api/tripal_stock.api.inc
Purpose: Return all stocks with a given name identifier which might match stock.name, stock.uniquename, dbxref.accession, stockprop.value where stockprop.type='synonym'

File

tripal_stock/api/tripal_stock.api.inc, line 37
Provides an application programming interface (API) to manage stocks

Code

function tripal_stock_get_stock_by_stock_id($stock_id) {

  $sql = "SELECT nid FROM {chado_stock} WHERE stock_id=%d";
  $r = db_fetch_object(db_query($sql, $stock_id));
  if (!empty($r->nid)) {
    return node_load($r->nid);
  }
  else {
    watchdog('tripal_stock', 'tripal_stock_get_stock_by_stock_id(!stock_id): no stock with that stock_id is sync\'d with drupal', array('!stock_id' => $stock_id), WATCHDOG_WARNING);
  }

  return 0;

}