function webform_update_7310 in Webform 7.3
Same name and namespace in other branches
- 7.4 webform.install \webform_update_7310()
Remove orphaned and unnecessary rows in the webform table.
File
- ./
webform.install, line 611 - Webform module install/schema hooks.
Code
function webform_update_7310() {
$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();
foreach ($result as $row) {
$empty_nids[] = $row->nid;
}
if (!empty($empty_nids)) {
db_delete('webform')
->condition('nid', $empty_nids, 'IN')
->execute();
}
}