ThinkPHP搭建cms-配置项管理

www.jswusn.com PHP 2018-12-09 22:16:03 2575次浏览

  ThinkPHP搭建cms-配置项管理

    /**
     * @param 添加配置
     * @author wusn <message@jswusn.com>
     */
    public function add_config(){
        $this->meta_title = '配置管理';
        $db = M($this->table);
        if(IS_POST){
            $data = I();
            $data['name'] = strtoupper(I('name'));
            $rules = array(
                array('status','1'),
                array('create_time','time',1,'function'),
            );
            $validate = array(
                array('name','require','名称不能为空'),
                array('name','','名称已存在',0,'unique',1),
                array('title','require','标题不能为空'),
                array('type','require','表单类型不能为空'),
            );
            if($db->auto($rules)->validate($validate)->create($data)){
//                p($data);die();
                if($db->add()){
                    $this->success('添加成功!',U('index'));
                }else{
                    $this->error('添加失败!');
                }
            }else{
                $this->error($db->getError());
            }

        }else{
            $this->form_type = C('FORM_ITEM_TYPE');
            $this->config_group = C('CONFIG_GROUP');
            $this->display('edit_config');
        }
    }


  以上是苏州网站建设分享关于ThinkPHP使用,如果你也有一些新颖的想法,可以跟苏州网站建设交流下。

技术分享

苏南名片

  • 电话:152-1887-1916
  • 邮箱:message@jswusn.com
  • 地址:江苏省苏州市相城区

热门文章

Copyright © 2018-2024 jswusn.com 版权所有

技术支持:苏州网站建设  苏ICP备18036849号