You are here

function _biblio_author_index_insert in Bibliography Module 5

1 call to _biblio_author_index_insert()
biblio_update_author_index in ./biblio.module

File

./biblio.module, line 3151

Code

function _biblio_author_index_insert($nid, $author, $rank) {
  $uc_author = trim(drupal_strtoupper($author));
  $result = db_query("SELECT * FROM {biblio_author_index} WHERE author = '%s'", $uc_author);
  $author_exist = db_num_rows($result);
  if ($author_exist) {
    $row = db_fetch_object($result);
    $result = db_query("INSERT INTO {biblio_has_author} (`nid`,`aid`,`rank`) VALUES (%d,%d,%d)", $nid, $row->aid, $rank);
  }
  else {
    $aid = db_next_id('{biblio_author_index}_aid');
    $result = db_query("INSERT INTO {biblio_author_index} (`aid`,`author`) VALUES (%d,'%s')", $aid, $uc_author);
    $result = db_query("INSERT INTO {biblio_has_author} (`nid`,`aid`,`rank`) VALUES (%d, %d, %d)", $nid, $aid, $rank);
  }
  return;
}