newsimon 发表于 2019-12-17 09:07:51

谁有还原数据库的代码? 在网上找的不好使

public function restore(){
         $file_name = './'.(string) $this->uri->segment(3).'/'.(string) $this->uri->segment(4);
      $this->load->helper('file');

                $sql = 'lvguanjia';
      $f = $file_name;
      $f = read_file($f);
      $f = preg_replace("/#(.*)\\s#(.*)TABLE(.*)(.*)\\s#/i","",$f);
      $f = write_file($file_name, $f);
      $file = $file_name;
      $f = file($file);

      $i = 0;
      $sql_arr = explode(';', $sql);
      $sql_count = count($sql_arr)-1;
      foreach ($sql_arr as $s){ $i ++;
            if ($i <= $sql_count){
                if (! $this->db->query($s)) show_error('导入'.$s.'表数据失败。');
            }
      }
    }
这是在网上找的用了用不好使

页: [1]
查看完整版本: 谁有还原数据库的代码? 在网上找的不好使