public function updateCache() { $ActionCache = F('updateCache'); if ($ActionCache) { $action = array_shift($ActionCache); F('updateCache', $ActionCache); switch ($action) { case "Config": $Model = K("Config"); $Model->updateCache(); $this->success('网站配置更新完毕...', U("updateCache"), 0); break; case "Model": $Model = K("Model"); $Model->updateCache(); $this->success('模型更新完毕...', U("updateCache"), 0); break; case "Field": $Model = new ModelFieldModel(1); $ModelCache = cache("model"); foreach ($ModelCache as $mid => $data) { $Model->updateCache($mid); } $this->success('字段更新完毕...', U("updateCache"), 0); break; case "Category": $Model = K("Category"); $Model->updateCache(); $this->success('栏目更新完毕...', U("updateCache"), 0); break; case "Node": $Model = K("Node"); $Model->updateCache(); $this->success('权限节点更新完毕...', U("updateCache"), 0); break; case "Table": cache('table', null); $this->success('数据表更新完毕...', U("updateCache"), 0); break; case "Role": $Model = K("Role"); $Model->updateCache(); $this->success('角色更新完毕...', U("updateCache"), 0); break; case "Flag": $Model = new FlagModel(1); $ModelCache = cache("model"); foreach ($ModelCache as $mid => $data) { $Model->updateCache($mid); } $this->success('Flag更新完毕...', U("updateCache"), 0); break; } } else { Dir::del('temp'); $this->success('缓存更新成功...', U('index'), 0); } }
public function updateCache() { if ($action = Q('get.action')) { switch ($action) { case "Config": $Model = K("Config"); $Model->updateCache(); $this->success('网站配置更新完毕...', U('updateCache', array('action' => 'Model')), 0); break; case "Model": $Model = K("Model"); $Model->updateCache(); $this->success('模型更新完毕...', U('updateCache', array('action' => 'Field')), 0); break; case "Field": $ModelCache = S("model"); foreach ($ModelCache as $mid => $data) { $_REQUEST['mid'] = $mid; $Model = new FieldModel(); $Model->updateCache($mid); } $this->success('字段更新完毕...', U('updateCache', array('action' => 'Category')), 0); break; case "Category": $Model = K('Category'); $Model->updateCache(); $this->success('栏目更新完毕...', U('updateCache', array('action' => 'Node')), 0); break; case "Node": $Model = K("Node"); $Model->updateCache(); $this->success('权限节点更新完毕...', U('updateCache', array('action' => 'Table')), 0); break; case "Table": Dir::del('temp/Table'); $this->success('数据表更新完毕...', U('updateCache', array('action' => 'Role')), 0); break; case "Role": $Model = K("Role"); $Model->updateCache(); $this->success('角色更新完毕...', U('updateCache', array('action' => 'Flag')), 0); break; case "Flag": $ModelCache = S("model"); foreach ($ModelCache as $mid => $data) { $_REQUEST['mid'] = $mid; $Model = new FlagModel(); $Model->updateCache(); } $this->display('success.php'); break; } } else { $this->success('缓存更新成功...', U('index'), 0); } }
public function updateCache() { $actionCache = S('updateCacheAction'); if ($actionCache) { while ($action = array_shift($actionCache)) { switch ($action) { case "Config": $Model = K("Config"); $Model->updateCache(); S('updateCacheAction', $actionCache); $this->success('网站配置更新完毕...', U('updateCache'), 0); break; case "Model": $Model = K("Model"); $Model->updateCache(); S('updateCacheAction', $actionCache); $this->success('模型更新完毕...', U('updateCache'), 0); break; case "Field": $ModelCache = S("model"); foreach ($ModelCache as $mid => $data) { $_REQUEST['mid'] = $mid; $Model = new FieldModel(); $Model->updateCache($mid); } S('updateCacheAction', $actionCache); $this->success('字段更新完毕...', U('updateCache'), 0); break; case "Category": $Model = K('Category'); $Model->updateCache(); S('updateCacheAction', $actionCache); $this->success('栏目更新完毕...', U('updateCache'), 0); break; case "Flag": $ModelCache = S("model"); foreach ($ModelCache as $mid => $data) { $_REQUEST['mid'] = $mid; $Model = new FlagModel(); $Model->updateCache(); } S('updateCacheAction', $actionCache); $this->success('Flag属性更新完毕...', U('updateCache'), 0); break; } } go('updateCache'); } else { S('updateCacheAction', null); $this->success('缓存更新成功...<script>setTimeout(function(){top.location.href="' . __MODULE__ . '"},2000);</script>', U('index')); } }
/** * 添加模型 */ public function addModel() { Q('model_name', '', 'trim'); Q('table_name', '', 'strtolower,trim'); $this->validate = array(array('model_name', 'nonull', '模型名称不能为空', 2, 1), array('table_name', 'nonull', '表名不能为空', 2, 1)); //验证表是否存在 if ($this->tableExists($_POST['table_name'])) { $this->error = '数据表已经存在'; return false; } //验证模型名称验证 if (M('model')->find(array('model_name' => $_POST['model_name']))) { $this->error = '模型已经存在'; return false; } //创建模型表 if ($this->create()) { $table_name = $this->data['table_name']; if ($this->createModelSql($table_name)) { //向模型表添加模型信息 $mid = $this->add(); if ($mid) { //创建Field表信息(初始模型字段) $db = M(); $db_prefix = C("DB_PREFIX"); $table = $table_name; require MODULE_PATH . '/Data/ModelSql/FieldInit.php'; if ($this->updateCache()) { //更新字段缓存 $_REQUEST['mid'] = $mid; $ModelField = new FieldModel(); $ModelField->updateCache(); //更新文章属性缓存 $FlagModel = new FlagModel(); $FlagModel->updateCache(); return $mid; } } else { return false; } } } }
/** * 添加模型 */ public function addModel($InsertData) { $this->validate = array(array('model_name', 'nonull', '模型名称不能为空', 2, 1), array('table_name', 'nonull', '表名不能为空', 2, 1)); $this->auto = array(array('table_name', 'strtolower', 'function', 2, 1)); //创建模型表 if ($this->create($InsertData)) { $data = $this->data; //验证表是否存在 if ($this->tableExists($data['table_name'])) { $this->error = '数据表已经存在'; return false; } if ($this->createModelSql($data['table_name'])) { //向模型表添加模型信息 $mid = $this->add(); if ($mid) { //创建Field表信息 $db = M(); $db_prefix = C("DB_PREFIX"); $table = $data['table_name']; require APP_PATH . '/Data/ModelSql/FieldInit.php'; if ($this->updateCache()) { //更新字段缓存 $ModelField = new ModelFieldModel($mid); $ModelField->updateCache(); //更新文章属性缓存 $FlagModel = new FlagModel($mid); $FlagModel->updateCache(); return $mid; } } else { return false; } } } else { return false; } }