Lighter weight biblio_load_contributors
Somehow I wrote the explanatory text for the function twice. It seems far too much for a small function so we're pulling out the philosophy and putting it here, for now.
<?php
/**
* Return array of single words from the contributor fields of biblio content.
*
* This is just a stripped down version of biblio_load_contributors, used as a
* helper module for our implementation of hook_cron which creates an index of
* keywords from the titles and authors of biblio nodes.
*
// we could get d.lastname, d.firstname in the query above, but if we
// are going to split on spaces just in case there are multiple firstnames
// or lastnames, we can just grab and split the single combined name field.
* This could probably be done more efficiently as part of the main query,
* using concat or something to make the authors one big field, but this is
* cleaner. @REVIEW
*
* @param vid
* The revision ID of a biblio node.
* @return
* An array of keywords from the contributors (authors) to a biblio node.
*/
// $query = 'SELECT bcd.name FROM {biblio_contributor} bc, {biblio_contributor_data} bcd WHERE bc.vid = %d AND bc.cid = bcd.cid;';
/**
* Load contributors (authors) for a given biblio node version id.
*
* This will be faster than biblio_load_contributors() not because it selects
* fewer fields but because it defines the fields and doesn't use an asterisk.
*/
function biblioreference_load_contributors($vid) {
$contributors = array();
$query = "SELECT lastname, firstname, initials, prefix
FROM {biblio_contributor} bc
INNER JOIN {biblio_contributor_data} bcd ON bc.cid=bcd.cid
WHERE bc.vid=%d
ORDER BY bc.rank ASC"; // do not change order of presentation
$result = db_query($query, $vid);
while ($creator = db_fetch_array($result)) {
$contributors[] = $creator;
}
return $contributors;
}
?>
Comments
Post new comment