search

Home  >  Q&A  >  body text

At the end of the article modification chapter, I changed add() to save(), but it still showed that the article modification failed. Please teach me how to change it. Thank you.

At the end of the article modification chapter, I changed add() to save(), but it still showed that the article modification failed. Please teach me how to change it, thank you

震惊!这个男人竟然在学校有...震惊!这个男人竟然在学校有...2765 days ago894

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-05-31 09:20:37

    public function edit(){
        $article=D('article');
        if(IS_POST){
            $data['title']=I('title');
            $data['content']=I('content');
            $data['desc']=I('desc');
            $data['cateid']=I('cateid');
            $data['id']=I('id');
            if($_FILES['pic']['tmp_name']!=''){
                $upload = new \Think\Upload();// 实例化上传类
                $upload->maxSize   =     3145728 ;// 设置附件上传大小
                $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
                $upload->savePath  =      './Public/Uploads/'; // 设置附件上传目录
                $upload->rootPath  =      './'; // 设置附件上传目录
                $info   =   $upload->uploadOne($_FILES['pic']);
                if(!$info){
                    $this->error($upload->getError());
                }else{
                   $data['pic']=$info['savepath'].$info['savename'];
                }
            }
            if($article->create($data)){
                $save=$article->save();
                if($save !== false){
                    $this->success('修改文章成功!',U('lst'));
                }else{
                    $this->error('修改文章失败!');
                }
            }else{
                $this->error($article->getError());
            }
     
            return;
        }
        $articles=$article->find(I('id'));
        $this->assign('articles',$articles);
        $cateres=D('cate')->select();
        $this->assign('cateres',$cateres);
        $this->display();
    }


    reply
    0
  • 震惊!这个男人竟然在学校有...

    Although the article has been modified successfully, the content displayed on the database and the page has not actually changed, which means it has not been saved. Do I need to change the added page?

    震惊!这个男人竟然在学校有... · 2017-05-31 18:57:59
    震惊!这个男人竟然在学校有...

    Wrong, it's a page change

    震惊!这个男人竟然在学校有... · 2017-05-31 18:58:23
  • PHP中文网

    PHP中文网2017-05-31 09:20:00

    If nothing has been changed, 0 will be returned. If it is 0, you will be prompted "No modifications were made". If it is greater than 0, it will be prompted that the modification was successful.

    reply
    0
  • Cancelreply