[已解决]请教:Think\Model:update方法不存在!的解决方法

浏览:5898 发布日期:2015/11/14 分类:求助交流 关键字: Think\Model 方法不存在
解决方法:控制器名<->模型名<->数据表名要一一对应
1、控制器GlobalController.class.php的代码:public function index(){
if(IS_POST){
            $site = D('Site');  //此处改为D('Global');
            if($site->create()){
                $site->update()!==false ? $this->success() : $this->error();
            }else{
                $this->error($site->getError());
            }
        }else{
        //显示模板
        }
}
2、模型GlobalModel.class.php的代码:    public function update(){
        $rs = $this->create();
        if(!$rs){ //数据对象创建错误
            return false;
        }

        if(empty($rs['id'])){
            $this->add();
        }else{
            $this->save();
        }
    }
3、点击提交修改后提示错误:
Think\Model:update方法不存在!
最佳答案
评论( 相关
后面还有条评论,点击查看>>