function tripal_chado_vocab_get_terms
3.x tripal_chado.vocab_storage.inc | tripal_chado_vocab_get_terms($vocabulary, $limit = 25, $element = 0) |
Implements hook_vocab_get_terms().
This hook is created by the Tripal module and is not a Drupal hook.
File
- tripal_chado/
includes/ tripal_chado.vocab_storage.inc, line 167
Code
function tripal_chado_vocab_get_terms($vocabulary, $limit = 25, $element = 0) {
// It's possible that Chado is not available (i.e. it gets renamed
// for copying) but Tripal has already been prepared and the
// entities exist. If this is the case we don't want to run the
// commands below.
if (!chado_table_exists('cvterm')) {
return FALSE;
}
$sql = "
SELECT CVT.cvterm_id
FROM {cvterm} CVT
INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
INNER JOIN {db} DB on DB.db_id = DBX.db_id
WHERE db.name = :dbname
ORDER BY CVT.name
";
$csql = "
SELECT COUNT(CVT.cvterm_id)
FROM {cvterm} CVT
INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
INNER JOIN {db} DB on DB.db_id = DBX.db_id
WHERE db.name = :dbname
";
$results = chado_pager_query($sql, array(':dbname' => $vocabulary), $limit, $element, $csql);
$terms = array();
while ($cvterm_id = $results->fetchField()) {
$match = array('cvterm_id' => $cvterm_id);
$cvterm = chado_generate_var('cvterm', $match);
$terms[] = _tripal_chado_format_term_description($cvterm);
}
return $terms;
}