You are here

function menu_node_update_6001 in Menu Node API 6

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

Erase bad records from the {menu_node} table.

File

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

Code

function menu_node_update_6001() {
  $return = array();
  $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");
  while ($data = db_fetch_object($result)) {
    $return[] = update_sql("DELETE FROM {menu_node} WHERE mlid = {$data->mlid} AND nid = {$data->nid}");
  }
  return $return;
}