function biblio_delete_orphan_keywords in Bibliography Module 6
Same name and namespace in other branches
- 6.2 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()
- 7 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()
- 7.2 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()
1 call to biblio_delete_orphan_keywords()
- biblio_cron in ./
biblio.module
File
- ./
biblio.keywords.inc, line 73
Code
function biblio_delete_orphan_keywords($force = FALSE) {
if (variable_get('biblio_keyword_orphan_autoclean', 0) || $force) {
$active_kids = array();
$all_kids = array();
$result = db_query('SELECT kid FROM {biblio_keyword} GROUP BY kid');
while ($kw = db_fetch_object($result)) {
$active_kids[] = $kw->kid;
}
$result = db_query('SELECT kid FROM {biblio_keyword_data} GROUP BY kid');
while ($kw = db_fetch_object($result)) {
$all_kids[] = $kw->kid;
}
$orphans = array_diff($all_kids, $active_kids);
if (!empty($orphans)) {
db_query('DELETE FROM {biblio_keyword_data} WHERE kid IN (' . implode(',', $orphans) . ')');
$count = db_affected_rows();
$message = t('%count orphaned keywords were deleted from the biblio_keyword_data table.', array(
'%count' => $count,
));
watchdog('biblio_cron', $message);
}
}
}