如何在codeigniter中导入加密的sql文件

时间:2018-01-21 11:56:26

标签: php mysql codeigniter

有没有办法在codeigniter中导入加密的sql文件? 这是我导入sql文件的代码,但我无法在加密的sql文件上执行此操作。

public function restore()
{
    $templine = '';

    $filename=('C:\Users\ASUS\Desktop\warms.sql');

    $lines = file($filename);

    // Loop through each line
    foreach ($lines as $line_num => $line) {
        // Only continue if it's not a comment
        if (substr($line, 0, 2) != '--' && $line != '') {
            // Add this line to the current segment
            $templine .= $line;
            // If it has a semicolon at the end, it's the end of the query
            if (substr(trim($line), -1, 1) == ';') {
            // Perform the query
                $this->load->model('Setting_model');
                $this->Setting_model->restore($templine);
                // Reset temp variable to empty
                $templine = '';
            ///////////////


            }
        }
    }
    $msg_info2 ='Database successfully Restored';
                $this->session->set_flashdata('msg_info2',$msg_info2);
}

我的备份数据库看起来像这些

public function back_up(){
    $this->load->dbutil();
    $db_format=array('format'=>'sql','filename'=>'warms_backup.sql',
                    'foreign_key_checks' => FALSE,
        );
    $backup=& $this->dbutil->backup($db_format);
    $encrypt_backup=$this->encrypt->encode($backup);
    $dbname='backup-on-'.date('Y-m-d').'.sql';
    $save='backup/'.$dbname;
    write_file($save,$backup);
    force_download($dbname,$encrypt_backup);
}

我使用codeigniter的库加密来加密它 提前致谢:D

0 个答案:

没有答案