function chado_get_organism_select_options

3.x tripal_chado.organism.api.inc chado_get_organism_select_options($syncd_only = TRUE)

Returns a list of organisms that are currently synced with Drupal to use in select lists.

Parameters

$syncd_only: Whether or not to return all chado organisms or just those sync'd with drupal. Defaults to TRUE (only sync'd organisms).

Return value

An array of organisms sync'd with Drupal where each value is the organism scientific name and the keys are organism_id's.

Related topics

2 calls to chado_get_organism_select_options()
obi__organism_widget::form in tripal_chado/includes/TripalFields/obi__organism/obi__organism_widget.inc
tripal_get_organism_select_options in tripal_chado/api/modules/tripal_chado.module.DEPRECATED.api.inc
Returns a list of organisms that are currently synced with Drupal to use in select lists.

File

tripal_chado/api/modules/tripal_chado.organism.api.inc, line 188
Provides API functions specificially for managing feature records in Chado.

Code

function chado_get_organism_select_options($syncd_only = TRUE) {
  $org_list = array();
  $org_list[] = 'Select an organism';

  if ($syncd_only) {
    $sql = "
      SELECT *
      FROM [chado_organism] CO
        INNER JOIN {organism} O ON O.organism_id = CO.organism_id
      ORDER BY O.genus, O.species
    ";
    $orgs = chado_query($sql);

    // Iterate through the organisms and build an array of those that are synced.
    foreach ($orgs as $org) {
      $org_list[$org->organism_id] = $org->genus . ' ' . $org->species;
    }
  }
  else {
    // use this SQL statement for getting the organisms
    $csql = "SELECT * FROM {organism} ORDER BY genus, species";
    $orgs = chado_query($csql);

    // Iterate through the organisms and build an array of those that are synced.
    foreach ($orgs as $org) {
      $org_list[$org->organism_id] = $org->genus . ' ' . $org->species;
    }
  }
  return $org_list;
}