你好 在文章修改的 最后一分钟 您的add() 应该改成save() 不然就是添加??
phpcn_u1336
phpcn_u1336 2017-04-02 13:12:45
0
4
1379

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

phpcn_u1336
phpcn_u1336

reply all(3)
数据分析师

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.

大家讲道理
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 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 author 2017-08-04 14:07:23
  • reply Adding a hidden field to edit.html is the same as the previous operation for link.html. <input type="hidden" name="id" value="{$articler.id}">
    97z author 2019-12-26 01:58:28
大家讲道理

是的,应该修改成save

  • reply 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 author 2017-08-09 15:56:58
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!