function tripal_cv_cvterm_name_autocomplete

2.x tripal_cv.DEPRECATED.inc tripal_cv_cvterm_name_autocomplete($cv_id, $string = '')
3.x tripal_cv.DEPRECATED.inc tripal_cv_cvterm_name_autocomplete($cv_id, $string = '')
1.x tripal_cv.api.inc tripal_cv_cvterm_name_autocomplete($cv_id, $string = '')

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

Parameters

$cv_id: The CV 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 string reference to 'tripal_cv_cvterm_name_autocomplete'
tripal_cv_menu in tripal_cv/tripal_cv.module
Implements hook_menu(). Registers all menu items associated with this module

File

tripal_cv/api/tripal_cv.api.inc, line 896
Controlled Vocabulary API

Code

function tripal_cv_cvterm_name_autocomplete($cv_id, $string = '') {
  $sql = "
    SELECT cvterm_id, name 
    FROM {cvterm} 
    WHERE cv_id = %d and lower(name) like lower('%s%%') 
    ORDER by name
  ";
  $results = chado_query($sql, $cv_id, $string);
  $items = array();
  while ($term = db_fetch_object($results)) {
    $items[$term->name] = $term->name;
  }
  drupal_json($items);
}