<< 点击返回技术分享列表

ASP网站Access数据库导出至PHP+MySQL,示例代码

浏览量 26627时间 2018-04-13
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("data/Data.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from Fk_Product",$conn,1,1);
while(! $rs->eof) {
$old_id=iconv('GBK','UTF-8//IGNORE',$rs->Fields["0"]->Value);
$name=iconv('GBK','UTF-8//IGNORE',$rs->Fields["1"]->Value);
$keyword=iconv('GBK','UTF-8//IGNORE',$rs->Fields["3"]->Value);
$description=iconv('GBK','UTF-8//IGNORE',$rs->Fields["4"]->Value);
$content=iconv('GBK','UTF-8//IGNORE',$rs->Fields["6"]->Value);
$pic=iconv('GBK','UTF-8//IGNORE',$rs->Fields["8"]->Value);
$pics=iconv('GBK','UTF-8//IGNORE',$rs->Fields["9"]->Value);
$type_id=iconv('GBK','UTF-8//IGNORE',$rs->Fields["12"]->Value);
$indate=iconv('GBK','UTF-8//IGNORE',$rs->Fields["23"]->Value);
$sql="insert into products(old_id,name,keyword,description,content,pic,pics,type_id,indate) values('$old_id','$name','$keyword','$description','$content','$pic','$pics','$type_id','$indate')";
$result=mysql_query($sql);
$rs->MoveNext();
}



上一篇:CentOS部署FTP注意事项
推荐阅读
免费体验新企云平台后台管理系统立即体验