function UpdateAreaGroupID($ParentAreaID, $GroupID) { $DB = new DB(); $sql = 'UPDATE `tbl_location` SET GroupID=' . $GroupID . ' WHERE AreaID=' . $ParentAreaID; if ($DB->Update($sql)) { $sql = 'Select AreaID FROM `tbl_location` WHERE ParentAreaID=' . $ParentAreaID; $rs = $DB->Select($sql); if ($rs) { foreach ($rs as $list) { UpdateAreaGroupID($list['AreaID'], $GroupID); } } } }
public function Areas() { $p = $this->__LoadParameters('globals'); if (is_array($p)) { foreach ($p as $key => $value) { $this->{$key} = $value; } } unset($p); if ($this->_POST) { $GroupID = _intval($this->_POST['GroupID'], true); $DB = new DB(); if ($this->_POST['OP'] == 'SetIsCity') { $Sql = 'UPDATE location set Property=1 WHERE AreaID=%d'; } elseif ($this->_POST['OP'] == 'SetIsState') { $Sql = 'UPDATE location set Property=0 WHERE AreaID=%d'; } elseif ($this->_POST['OP'] == 'SetIsTown') { $Sql = 'UPDATE location set Property=2 WHERE AreaID=%d'; } elseif ($this->_POST['OP'] == 'SetIsTop') { $Sql = 'UPDATE location set IsTop=1 WHERE AreaID=%d'; } elseif ($this->_POST['OP'] == 'SetUnIsTop') { $Sql = 'UPDATE location set IsTop=0 WHERE AreaID=%d'; } if (is_array($this->_POST['AreaID'])) { foreach ($this->_POST['AreaID'] as $AreaID) { if ($this->_POST['OP'] == 'SetGroup') { UpdateAreaGroupID($AreaID, $GroupID); } else { $DB->Update(sprintf($Sql, $AreaID)); } } } $ParentAreaID = _intval($this->_POST['ParentAreaID'], true); $this->__Message('操作已完成!', UrlRewriteSimple('AreasManager', 'Areas') . '&ParentAreaID=' . $ParentAreaID, '继续操作'); } $this->ParentAreaID = _intval($this->_GET['ParentAreaID']); if ($this->_GET['AreaID']) { $AreaDetail = GetAreaDetail($this->_GET['AreaID']); if ($AreaDetail) { $this->AreaDetail = $AreaDetail; } } }