function tripal_db_dbxref_accession_autocomplete

3.x tripal_db.module tripal_db_dbxref_accession_autocomplete($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

1 string reference to 'tripal_db_dbxref_accession_autocomplete'
tripal_db_menu in legacy/tripal_db/tripal_db.module
Implements hook_menu().

File

legacy/tripal_db/tripal_db.module, line 132
General functions for the db module

Code

function tripal_db_dbxref_accession_autocomplete($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);
}