You are here

function menu_node_update_6001 in Menu Node API 7

Same name and namespace in other branches
  1. 6 menu_node.install \menu_node_update_6001()

Erase bad records from the {menu_node} table.

File

./menu_node.install, line 89
Install file for Menu Node API.

Code

function menu_node_update_6001() {
  $result = db_query("SELECT mn.mlid, mn.nid FROM {menu_node} mn LEFT JOIN {node} n ON mn.nid = n.nid LEFT JOIN {menu_links} ml ON ml.mlid = mn.mlid WHERE n.nid IS NULL OR ml.mlid IS NULL");
  foreach ($result as $data) {
    db_delete('menu_node')
      ->condition('mlid', $data->mild)
      ->condition('nid', $data->nid)
      ->execute();
  }
  return t('Erased bad records from the {menu_node} table.');
}