动易数据转成dedecms的php程序
程序员文章站
2022-04-28 14:38:10
ps:这个可以举一反三,如新云或nb等asp文章系统都可转为dedecms或其它php的cms 复制代码 代码如下:
ps:这个可以举一反三,如新云或nb等asp文章系统都可转为dedecms或其它php的cms
<?php
//读取mdb数据库例程
set_time_limit(0);
$conn = new com("adodb.connection");
$connstr = "driver={microsoft access driver (*.mdb)}; dbq=". realpath("e:\web2\qq.mdb");
$conn->open($connstr);
$rs = new com("adodb.recordset");
$rs->open("select * from pe_article where articleid>0 order by articleid asc",$conn,1,1);
$conn2 = mysql_connect("localhost","root","");
mysql_select_db("dede",$conn2);
mysql_query("set names gbk",$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 = "select id from dede_archives where id='$id'";
$rs0 = mysql_query($sql0,$conn2);
$row = mysql_fetch_array($rs0);
if(intval($row['id'])==0){
$sql1 = "insert into dede_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 "<br>";
echo mysql_error();
echo "<br>";
//exit;
}
$id2 = mysql_insert_id();
if($id2>0){
$sql2 = "insert into dede_addonarticle (aid ,typeid, body ) values('$id','$classid','$content');";
$rs2 = mysql_query($sql2,$conn2);
if(!$rs2){
echo $sql2;
echo "<br>";
echo mysql_error();
echo "<br>";
//exit;
}
}
}
$rs->movenext();
$i++;
if($i%50==0)sleep(5);
}
echo "完成";
?>
复制代码 代码如下:
<?php
//读取mdb数据库例程
set_time_limit(0);
$conn = new com("adodb.connection");
$connstr = "driver={microsoft access driver (*.mdb)}; dbq=". realpath("e:\web2\qq.mdb");
$conn->open($connstr);
$rs = new com("adodb.recordset");
$rs->open("select * from pe_article where articleid>0 order by articleid asc",$conn,1,1);
$conn2 = mysql_connect("localhost","root","");
mysql_select_db("dede",$conn2);
mysql_query("set names gbk",$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 = "select id from dede_archives where id='$id'";
$rs0 = mysql_query($sql0,$conn2);
$row = mysql_fetch_array($rs0);
if(intval($row['id'])==0){
$sql1 = "insert into dede_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 "<br>";
echo mysql_error();
echo "<br>";
//exit;
}
$id2 = mysql_insert_id();
if($id2>0){
$sql2 = "insert into dede_addonarticle (aid ,typeid, body ) values('$id','$classid','$content');";
$rs2 = mysql_query($sql2,$conn2);
if(!$rs2){
echo $sql2;
echo "<br>";
echo mysql_error();
echo "<br>";
//exit;
}
}
}
$rs->movenext();
$i++;
if($i%50==0)sleep(5);
}
echo "完成";
?>
上一篇: PHP字符转义相关函数小结(php下的转义字符串)
下一篇: [PHP] 使用反射实现的控制反转