delete.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003 This file  is part  of HGSM.   HGSM is a  web application  for keeping
00004 information about a hierarchical structure (in this case a grid).
00005 
00006 Copyright 2005, 2006 Dashamir Hoxha, dashohoxha@users.sourceforge.net
00007 
00008 HGSM is free software; you  can redistribute it and/or modify it under
00009 the terms of  the GNU General Public License as  published by the Free
00010 Software  Foundation; either  version 2  of the  License, or  (at your
00011 option) any later version.
00012 
00013 HGSM is  distributed in the hope  that it will be  useful, but WITHOUT
00014 ANY WARRANTY; without even  the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
00016 for more details.
00017 
00018 You  should have received  a copy  of the  GNU General  Public License
00019 along with HGSM; if not,  write to the Free Software Foundation, Inc.,
00020 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021 */
00022 
00038 function del_sites($site_list)
00039 {
00040   //delete the related site_contacts
00041   $query = "DELETE FROM site_contacts WHERE site_id IN ($site_list)";
00042   WebApp::execQuery($query);
00043 
00044   //delete the related site_downtimes
00045   $query = "DELETE FROM site_downtimes WHERE site_id IN ($site_list)";
00046   WebApp::execQuery($query);
00047 
00048   //delete the related site_nodes
00049   $query = "DELETE FROM site_nodes WHERE site_id IN ($site_list)";
00050   WebApp::execQuery($query);
00051 
00052   //delete the sites in the list
00053   $query = "DELETE FROM sites WHERE site_id IN ($site_list)";
00054   WebApp::execQuery($query);
00055 }
00056 
00061 function del_countries($country_list)
00062 {
00063   //get a list of the sites in each country
00064   $query = "SELECT site_id FROM sites WHERE country_id IN ($country_list)";
00065   $rs = WebApp::execQuery($query);
00066   $arr_sites = $rs->getColumn('site_id');
00067   $site_list = "'" . implode("', '", $arr_sites). "'";
00068 
00069   //delete the related sites
00070   del_sites($site_list);
00071 
00072   //delete the countries in the list
00073   $query = "DELETE FROM countries WHERE country_id IN ($country_list)";
00074   WebApp::execQuery($query);
00075 }
00076 
00081 function del_rocs($roc_list)
00082 {
00083   //get a list of the countries in each ROC
00084   $query = "SELECT country_id FROM countries WHERE ROC_id IN ($roc_list)";
00085   $rs = WebApp::execQuery($query);
00086   $arr_countries = $rs->getColumn('country_id');
00087   $country_list = "'" . implode("', '", $arr_countries). "'";
00088 
00089   //delete the related countries
00090   del_countries($country_list);
00091 
00092   //delete the ROCs in the list
00093   $query = "DELETE FROM ROCs WHERE ROC_id IN ($roc_list)";
00094   WebApp::execQuery($query);
00095 }
00096 ?>

Generated on Fri Jan 20 10:34:52 2006 for HGSM by  doxygen 1.4.5