You are here

function _id_by_name in Bibliography Module 6

Same name and namespace in other branches
  1. 7 biblio.install \_id_by_name()
  2. 7.2 biblio.install \_id_by_name()
1 call to _id_by_name()
_add_custom_field_data in ./biblio.install

File

./biblio.install, line 1255
Install file for biblio module

Code

function _id_by_name($table, $name, $id = NULL, $build = NULL) {
  static $result = NULL;
  if (!empty($build)) {

    //refresh cache from table
    unset($result[$build['tablename']]);
    $res = db_query("SELECT " . $build['name_column'] . ", " . $build['id_column'] . " FROM {" . $build['tablename'] . "}");
    while ($row = db_fetch_array($res)) {
      $result[$build['tablename']][$row[$build['name_column']]] = $row[$build['id_column']];
    }
    return;
  }
  $name = trim($name);
  if (isset($result[$table][$name])) {
    return $result[$table][$name];
  }
  if ($id) {
    $result[$table][$name] = $id;
  }
  return FALSE;
}