复制代码 代码如下:
$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);
}
新闻热点
疑难解答