function subscriptions_content_update_1 in Subscriptions 6
Same name and namespace in other branches
- 5.2 subscriptions_content.install \subscriptions_content_update_1()
Database update function 1.
Remove content type subscriptions left over from deleted content types.
File
- ./
subscriptions_content.install, line 24 - Subscriptions Content module installation.
Code
function subscriptions_content_update_1() {
$result = db_query("SELECT s.value AS tid FROM {subscriptions_queue} s LEFT JOIN {node_type} t ON s.value = t.type WHERE s.module = 'node' AND s.field = 'type' AND t.type IS NULL");
while ($orphan = db_fetch_array($result)) {
$orphans[] = $orphan['tid'];
$placeholders[] = "'%s'";
}
if (isset($orphans)) {
db_query("DELETE FROM {subscriptions_queue} WHERE module = 'node' AND field = 'type' AND value IN (" . implode(',', $placeholders) . ")", $orphans);
$orphans = $placeholders = NULL;
}
$result = db_query("SELECT s.value AS tid FROM {subscriptions} s LEFT JOIN {node_type} t ON s.value = t.type WHERE s.module = 'node' AND s.field = 'type' AND t.type IS NULL");
while ($orphan = db_fetch_array($result)) {
$orphans[] = $orphan['tid'];
$placeholders[] = "'%s'";
}
if (isset($orphans)) {
db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'type' AND value IN (" . implode(',', $placeholders) . ")", $orphans);
}
return array();
}