Example #1
0
 /**
  * 删除模型
  */
 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']);
 }