时间:2021-07-01 10:21:17 帮助过:3人阅读
$dbfile="test.sql";
$content=iconv("utf-8","gb2312",file_get_contents($dbfile));
//获取创建的数据
//去掉注释
$content=preg_replace("/--.*n/iu","",$content);
//替换前缀
$content=str_replace("ct_",table_pre,$content);
$carr=array();
$iarr=array();
//提取create
preg_match_all("/create table .*(.*).*;/ius",$content,$carr);
$carr=$carr[0];
foreach($carr as $c)
{
@mysql教程_query($c,$link);
}
//提取insert
preg_match_all("/insert into .*(.*);/ius",$content,$iarr);
$iarr=$iarr[0];
//插入数据
foreach($iarr as $c)
{
@mysql_query($c,$link);
}
http://www.bkjia.com/PHPjc/630757.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630757.htmlTechArticle分享一下 我所用的方法。只对php教程myadmin导出的sql文件有效 $dbfile=test.sql; $content=iconv(utf-8,gb2312,file_get_contents($dbfile)); //获取创建的数据...