复制代码 代码如下:
//读取mdb数据库例程
set_time_limit(0);
$conn=newcom("ADODB.Connection");
$connstr="DRIVER={MicrosoftAccessDriver(*.mdb)};DBQ=".realpath("E:web2qq.mdb");
$conn->Open($connstr);
$rs=newcom("ADODB.RecordSet");
$rs->Open("select*fromPE_ArticleWhereArticleID>0orDERBYArticleIDASC",$conn,1,1);
$conn2=mysql_connect("localhost","root","");
mysql_select_db("dede",$conn2);
mysql_query("SETNAMESGBK",$conn2);
$i=0;
while(!$rs->eof){
$id=$rs->Fields('ArticleID')->value;
$title=addslashes($rs->Fields('Title')->value);
$classid=$rs->Fields('ClassID')->value;
$keywordstr=$rs->Fields('Keyword')->value;
$keywordstr=str_replace("|","",$keywordstr);
$keyword=trim($keywordstr);
$datestr=$rs->Fields('UpdateTime')->value;
$datearr=explode("-",$datestr);
$yy=$datearr[0];
$mm=$datearr[1];
$dd=rand(1,28);
$time=mktime(0,0,0,$mm,$dd,$yy);
$content=addslashes($rs->Fields('Content')->value);
$content=str_replace('[InstallDir_ChannelDir]{$UploadDir}','/UploadFiles',$content);
//$uploadfile=$rs->Fields('UploadFiles')->value;
$sql0="selectIDfromdede_archiveswhereID='$id'";
$rs0=mysql_query($sql0,$conn2);
$row=mysql_fetch_array($rs0);
if(intval($row['ID'])==0){
$sql1="insertintodede_archives(ID,typeid,channel,title,sortrank,pubdate,senddate,adminID,keywords)values('$id','$classid',1,'$title','$time','$time','$time',1,'$keyword')";
$rs1=mysql_query($sql1,$conn2);
if(!$rs1){
echo$sql1;
echo"
";
echomysql_error();
echo"
";
//exit;
}
$id2=mysql_insert_id();
if($id2>0){
$sql2="insertintodede_addonarticle(aid,typeid,body)values('$id','$classid','$content');";
$rs2=mysql_query($sql2,$conn2);
if(!$rs2){
echo$sql2;
echo"
";
echomysql_error();
echo"
";
//exit;
}
}
}
$rs->MoveNext();
$i++;
if($i%50==0)sleep(5);
}
echo"完成";
?>