function chado_autocomplete_cv
3.x tripal_chado.cv.api.inc | chado_autocomplete_cv($string = '') |
This function is intended to be used in autocomplete forms.
This function searches for a matching controlled vobulary name.
Parameters
$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_cv()
- tripal_autocomplete_cv in tripal_chado/
api/ modules/ tripal_chado.module.DEPRECATED.api.inc - This function is intended to be used in autocomplete forms.
1 string reference to 'chado_autocomplete_cv'
- tripal_chado_menu in tripal_chado/
tripal_chado.module - Implements hook_menu().
File
- tripal_chado/
api/ modules/ tripal_chado.cv.api.inc, line 1432 - Provides API functions specificially for managing controlled vocabulary records in Chado.
Code
function chado_autocomplete_cv($string = '') {
$sql = "
SELECT CV.cv_id, CV.name
FROM {cv} CV
WHERE lower(CV.name) like lower(:name)
ORDER by CV.name
LIMIT 25 OFFSET 0
";
$results = chado_query($sql, array(':name' => $string . '%'));
$items = array();
foreach ($results as $cv) {
$items[$cv->name] = $cv->name;
}
drupal_json_output($items);
}