function _id_by_name in Bibliography Module 7.2
Same name and namespace in other branches
- 6 biblio.install \_id_by_name()
- 7 biblio.install \_id_by_name()
2 calls to _id_by_name()
File
- ./
biblio.install, line 1454
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'] . "}", array(), array(
'fetch' => PDO::FETCH_ASSOC,
));
foreach ($res as $row) {
$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;
}