TP 删除备份数据

来源:互联网 发布:淘宝评价了怎么看不到 编辑:程序博客网 时间:2024/05/22 08:01
//删除备份数据
     public function unLinkDate()
     {
         $session = $_SESSION['userName'];
         if(empty($session)) $this->ajaxReturn('','未登录!',-1);
         $id = $this->_post('id');
         $db = M('datapath');
         $where['id'] = $id;
         $result = $db->where($where)->select();
         if($result){
             $data_Path = $result[0]['path'];
             $filename = $result[0]['filename'];
             $file_Path = $data_Path.$filename;
             if(file_exists($file_Path)){
                 $res = $db->where($where)->delete();
                 if($res){
                     if(!unlink($file_Path)) $this->ajaxReturn('','删除失败!',-2);            
                    $this->ajaxReturn('','删除成功!',1);
                 }else{
                     $this->ajaxReturn('','删除失败!',-3);            
                 }
                 
             }else{
                 $this->ajaxReturn('','文件不存在!',-4);
             }
             
         }else{
             $this->ajaxReturn('','没有此数据!',-5);    
         }
     }
0 0