function chado_autocomplete_dbxref

3.x tripal_chado.db.api.inc chado_autocomplete_dbxref($db_id, $string = '')

This function is intended to be used in autocomplete forms for searching for accession that begin with the provided string.

Parameters

$db_id: The DB ID in which to search for the term.

$string: The string to search for.

Return value

A json array of terms that begin with the provided string.

Related topics

1 call to chado_autocomplete_dbxref()
tripal_autocomplete_dbxref in tripal_chado/api/modules/tripal_chado.module.DEPRECATED.api.inc
This function is intended to be used in autocomplete forms for searching for accession that begin with the provided string.
1 string reference to 'chado_autocomplete_dbxref'
tripal_chado_menu in tripal_chado/tripal_chado.module
Implements hook_menu().

File

tripal_chado/api/modules/tripal_chado.db.api.inc, line 591
Provides API functions specificially for managing external database reference records in Chado.

Code

function chado_autocomplete_dbxref($db_id, $string = '') {
  if (!$db_id) {
    return drupal_json_output(array());
  }
  $sql = "
    SELECT dbxref_id, accession
    FROM {dbxref}
    WHERE db_id = :db_id and lower(accession) like lower(:accession)
    ORDER by accession
    LIMIT 25 OFFSET 0
  ";
  $results = chado_query($sql, array(':db_id' => $db_id, ':accession' => $string . '%'));
  $items = array();
  foreach ($results as $ref) {
    $items[$ref->accession] = $ref->accession;
  }

  drupal_json_output($items);
}