Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 /**
  * 添加模型
  */
 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;
     }
 }
Exemplo n.º 3
0
 public function updateAllCache()
 {
     $modelModel = K("Model");
     $modelModel->updateCache();
     $modelModel = K("Category");
     $modelModel->updateCache();
     $modelModel = K("Role");
     $modelModel->updateCache();
     $modelModel = K("Node");
     $modelModel->updateCache();
     $modelCache = cache('model');
     foreach ($modelCache as $model) {
         $fieldModel = new ModelFieldModel($model['mid']);
         $fieldModel->updateCache();
     }
     $this->success('缓存更新成功');
 }
Exemplo n.º 4
0
 public function updateCache()
 {
     $mid = Q('mid', 0, 'intval');
     if (!$mid) {
         $this->_ajax(0, '参数错误');
     }
     $fieldModel = new ModelFieldModel($this->_mid);
     if ($fieldModel->updateCache($mid)) {
         $this->_ajax(1, '更新成功');
     } else {
         $this->_ajax(0, $fieldModel->error);
     }
 }