function _biblio_field_id_by_name in Bibliography Module 6.2
Maps CSV field data to table column names for fields in the biblio module.
This function does what ...
Parameters
string $table: The name of the database table.
string $csv_field: The name of the field in input data file.
string $sql_field: (optional) Name of the sql field that maps to $csv_field.
array $build: (optional) An associative array with the following keys:
- tablename: The name of the biblio table.
- name_column: The label for this field from the CSV file.
- id_column: The column name in SQL table for this field.
return string|false
1 call to _biblio_field_id_by_name()
- _biblio_types_customize_fields in ./
biblio.install - Creates customized fields for bibliographic types based on a CSV data file.
File
- ./
biblio.install, line 1713 - Install, update, and uninstall functions for the biblio module.
Code
function _biblio_field_id_by_name($table, $csv_field, $sql_field = NULL, $build = NULL) {
static $fields = NULL;
// Reset the static $fields variable with data from the database table.
if (!empty($build)) {
unset($fields[$build['tablename']]);
$sql = "SELECT " . $build['name_column'] . ", " . $build['id_column'] . " " . "FROM {" . $build['tablename'] . "}";
$resource = db_query($sql);
while ($row = db_fetch_array($resource)) {
$fields[$build['tablename']][$row[$build['name_column']]] = $row[$build['id_column']];
}
return;
}
$name = trim($csv_field);
if (isset($fields[$table][$name])) {
return $fields[$table][$name];
}
if ($sql_field) {
$fields[$table][$name] = $sql_field;
}
return FALSE;
}