|
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.'表数据失败。');
}
}
}
这是在网上找的用了用不好使
|
|