Home  >  Q&A  >  body text

你好 在文章修改的 最后一分钟 您的add() 应该改成save() 不然就是添加??

你好 在文章修改的  最后一分钟  您的add() 应该改成save()   不然就是添加??

phpcn_u1336phpcn_u13362777 days ago1382

reply all(4)I'll reply

  • 数据分析师

    数据分析师2017-10-01 01:14:14

    Hello, at the last minute of the article modification, your add() should be changed to save(), or else just add? ? -PHP Chinese website Q&A-Hello, at the last minute of article modification, your add() should be changed to save(), or should it be added? ? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-29 11:20:19

    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
  • En_Answer

    Hello, according to this modification, the prompt is successful, but the return interface has not changed, and the database has not changed either.

    En_Answer · 2017-08-04 14:07:23
    97z

    Adding a hidden field to edit.html is the same as the previous operation for link.html.

    97z · 2019-12-26 01:58:28
  • 大家讲道理

    大家讲道理2017-04-04 09:16:21

    是的,应该修改成save

    reply
    0
  • En_Answer

    Hello, after I changed ADD to save, it always prompts that the modification failed, but if it is add, it can be added successfully. What is the situation?

    En_Answer · 2017-08-09 15:56:58
  • Cancelreply