You are here

function biblio_get_keyword_by_name in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio.keywords.inc \biblio_get_keyword_by_name()
  2. 6 biblio.keywords.inc \biblio_get_keyword_by_name()
  3. 7.2 includes/biblio.keywords.inc \biblio_get_keyword_by_name()

Parameters

$name:

Return value

array of keywords

4 calls to biblio_get_keyword_by_name()
BiblioKeywordWebTestCase::testBiblioGetKeywordByName in tests/BiblioKeywordWebTestCase.test
biblio_add_merge_keyword in includes/biblio.admin.inc
_state
biblio_get_kid_by_name in includes/biblio.keywords.inc
Gets a keyword ID using keyword text as the key.
biblio_insert_keywords in includes/biblio.keywords.inc
Insert keywords into the database.

File

includes/biblio.keywords.inc, line 27
Contains all keyword related functions.

Code

function biblio_get_keyword_by_name($name) {
  static $keywords = array();
  if (!($kid = array_search($name, $keywords))) {
    $term = db_query("SELECT kd.kid, kd.word, COUNT(*) as use_count FROM {biblio_keyword_data} kd\n    \t\t\t\t\t\t\t\tLEFT JOIN {biblio_keyword} bk on bk.kid = kd.kid\n    \t\t\t\t\t\t\t\tWHERE LOWER(kd.word) = LOWER(:name)\n    \t\t\t\t\t\t\t\tGROUP BY kd.kid, kd.word", array(
      ':name' => trim($name),
    ))
      ->fetchObject();
    if ($term) {
      $keywords[$term->kid] = $term;
      return $keywords[$term->kid];
    }
    else {
      return FALSE;
    }
  }
  return $keywords[$kid];
}