/** * 添加模型 */ public function action() { $this->db()->transaction(); /** * 插入模型信息 */ $addModelresult = \Model\ModelManage::addModel(); if ($addModelresult === false) { $this->db()->rollBack(); $this->error('添加模型失败'); } /** * 插入模型菜单 */ $addMenuResult = \Model\Menu::insertModelMenu($addModelresult['lang_key'], '9', GROUP . "-{$addModelresult['model_name']}-index"); if ($addMenuResult === false) { $this->db()->rollBack(); $this->error('插入菜单失败'); } /** * 插入初始化的字段 */ \Model\ModelManage::setInitField($addModelresult['model_id']); $this->db()->commit(); $initResult = \Model\ModelManage::initModelTable($addModelresult['model_name']); $this->success('添加模型成功', $this->url(GROUP . '-Model-index')); }
/** * 添加模型 */ public function action() { $this->db()->transaction(); /** * 插入模型信息 */ $addModelresult = \Model\Model::addModel(); if ($addModelresult['status'] == false) { $this->db()->rollBack(); $this->error($addModelresult['mes']); } /** * 插入模型菜单 */ $addMenuResult = \Model\Menu::insertModelMenu($addModelresult['mes']['lang_key'], '9', "Team-{$addModelresult['mes']['model_name']}-index"); if ($addMenuResult == false) { $this->db()->rollBack(); $this->error($GLOBALS['_LANG']['MENU']['ADD_MENU_FAIL']); } /** * 插入初始化的字段 */ $setFieldResult = \Model\Model::setInitField($addModelresult['mes']['model_id']); if ($setFieldResult['status'] == false) { $this->db()->rollBack(); $this->error($setFieldResult['mes']); } $this->db()->commit(); $initResult = \Model\Model::initModelTable($addModelresult['mes']['model_name']); if ($setFieldResult['status'] == false) { $log = new \Expand\Log(); $failLog = "Create Model Table Field: {$setFieldResult['mes']}" . date("Y-m-d H:i:s"); $log->creatLog('modelError', $failLog); $this->error($GLOBALS['_LANG']['MODEL']['CREATE_TABLE_ERROR']); } $this->success($GLOBALS['_LANG']['MODEL']['ADD_MODEL_SUCCESS'], $this->url('Team-Model-index')); }