用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1212|回复: 0
收起左侧

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

[复制链接]
发表于 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.'表数据失败。');
            }
        }
    }
这是在网上找的用了用不好使

本版积分规则