You are here

function biblio_get_cid_by_name in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 includes/biblio.contributors.inc \biblio_get_cid_by_name()

Retrieves biblio contributor id based on exact match of contributor name.

// @todo: What happens if array or non-existant name string passed?

Parameters

string $name: Name of a contributor.

Return value

int|null A contributor object if found; otherwise null

1 call to biblio_get_cid_by_name()
_biblio_save_contributors in includes/biblio.contributors.inc
Save contributors to the database.

File

includes/biblio.contributors.inc, line 51
Functions related to contributors in Drupal biblio module.

Code

function biblio_get_cid_by_name($name) {
  static $contributor = array();
  $cid = NULL;
  if (!isset($contributor[$name])) {
    $cid = db_result(db_query("SELECT cid FROM {biblio_contributor_data} bcd WHERE bcd.name = '%s'", array(
      $name,
    )));
    if (!$cid) {
      $cid = db_result(db_query("SELECT aka FROM {biblio_contributor_aka_data} bcad WHERE bcad.name = '%s'", array(
        $name,
      )));
    }
    if ($cid) {
      $contributor[$name] = $cid;
    }
  }
  return isset($contributor[$name]) ? $contributor[$name] : NULL;
}