/** * 删除模型 */ public function action() { $modelId = $this->isG('id', $GLOBALS['_LANG']['COMMON']['DELETE_ID']); $model = \Model\Model::findModel($modelId); if (empty($model)) { $this->error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_MODEL']); } $this->db()->transaction(); $deleteModelResult = \Model\Model::deleteModel($modelId); if (empty($deleteModelResult)) { $this->db()->rollBack(); $this->error($GLOBALS['_LANG']['COMMON']['DELETE_ERROR']); } $deleteModelField = \Model\Field::deleteModelField($modelId); if (empty($deleteModelField)) { $this->db()->rollBack(); $this->error($GLOBALS['_LANG']['MODEL']['DELETE_MODEL_FIELD_FAIL']); } $deleteMenuResult = \Model\Menu::deleteMenu(strtoupper($model['model_name']) . "_LIST"); if (empty($deleteMenuResult)) { $this->db()->rollBack(); $this->error($GLOBALS['_LANG']['MENU']['DELETE_MENU_FAIL']); } $this->db()->commit(); $alterTableResult = \Model\Model::alterTable(strtolower($model['model_name'])); if (empty($alterTableResult)) { $log = new \Expand\Log(); $failLog = "Alter Model Table Field: {$this->prefix}{$model['model_name']}" . date("Y-m-d H:i:s"); $log->creatLog('modelError', $failLog); $this->error($GLOBALS['_LANG']['MODEL']['ALTER_TABLE_ERROR']); } $this->success($GLOBALS['_LANG']['COMMON']['DELETE_SUCCESS']); }
/** * 删除模型 */ public function action() { $modelId = $this->isG('id', '请选择要删除的数据!'); $model = \Model\ModelManage::findModel($modelId); if (empty($model)) { $this->error('模型不存在'); } $this->db()->transaction(); $deleteModelResult = \Model\ModelManage::deleteModel($modelId); if (empty($deleteModelResult)) { $this->db()->rollBack(); $this->error('删除模型失败'); } $deleteModelField = \Model\Field::deleteModelField($modelId); if (empty($deleteModelField)) { $this->db()->rollBack(); $this->error('移除模型字段记录失败'); } $deleteMenuResult = \Model\Menu::deleteMenu($model['lang_key']); if (empty($deleteMenuResult)) { $this->db()->rollBack(); $this->error('删除菜单失败'); } $this->db()->commit(); $alterTableResult = \Model\ModelManage::alterTable(strtolower($model['model_name'])); if (empty($alterTableResult)) { $log = new \Expand\Log(); $failLog = "Alter Model Table Field: {$this->prefix}{$model['model_name']}" . date("Y-m-d H:i:s"); $log->creatLog('modelError', $failLog); $this->error('删除数据库表失败'); } $this->success('删除成功'); }