function webform_update_6325 in Webform 6.3
Remove orphaned and unnecessary rows in the webform table.
File
- ./
webform.install, line 1385 - Webform module install/schema hooks.
Code
function webform_update_6325() {
$ret = array();
$result = db_query("SELECT nid FROM {webform} WHERE\n nid NOT IN\n (SELECT DISTINCT(w1.nid) FROM {webform} w1 INNER JOIN {webform_component} wc ON w1.nid = wc.nid)\n AND nid NOT IN\n (SELECT w2.nid FROM {webform} w2 INNER JOIN {node} n ON w2.nid = n.nid WHERE n.type = 'webform')");
$empty_nids = array();
while ($row = db_fetch_object($result)) {
$empty_nids[] = $row->nid;
}
if (!empty($empty_nids)) {
$empty_list = implode(',', $empty_nids);
$ret[] = update_sql("DELETE FROM {webform} WHERE nid in ({$empty_list})");
}
return $ret;
}