access转mysql 注定字段

2013-10-09 浏览:1593
access转mysql 注定字段
评论:(0)复制地址

<?
/**
 *利用COM打开ACCESS,然后正常插入到数据表中
 *
 * @Author    苗景云
 * @Date       2013/10/09
 */

//利用COM打开ACCESS数据表
$conn = @new com("ADODB.Connection") or die("ADO连接创造失败");
$connstr = "Provider=MSDASQL.1;Data Source=jingdianniansong.mdb;";
$conn->open($connstr);
$rs = @new com("ADODB.RecordSet") or die("ADO记录集创建失败");
$db = "SELECT * FROM Content";
$rs->Open($db,$conn,1,1);

$conn = mysql_connect("localhost","root","root123") or die("连接主机失败");
mysql_query('set names "utf-8"');
mysql_select_db("foshangmusic") or die("打开数据库失败");

//循环取出,插入到MYSQL数据表的相应字段中!
while(!$rs->eof)
{
//    $a6 = $rs->Fields["a6"]; //此行用于截取
//    if (strlen($a6) > 30)
//    {
//        $a6 = substr($a6,0,15);
//        $a6 = $a6 . "..";
//    }
    $query = "INSERT INTO foshang_music_bak SET
                            name = '{$rs->Fields["title"]}',
                            cid = 3,
                            cname = '经典念诵',
                            aid = 0,
                            aname = '非专辑单曲',
                            uid = 0,
                            uname = '佛商网',
                            tpl = 'music_info.html',
                            path = '',
                            order_num = 0,
                            hit = 0,
                            tdy_hit = 0,
       mth_hit = 0,
       mark = 0,
       mark_times = 0,
       dwn_times = 0,
       error = 0,
       sto_num = 0,
       up = 0,
       down = 0,
       lsn_gpid = 0,
       lsn_gpname = '',
       lsn_money = 0,
       dwn_gpid = 7,
       dwn_gpname = 'VIP',
       dwn_money = 0,
       sty_id = 1,
       sty_name = '梵呗乐',
       area_id = 1,
       area_name = '内地',
       lan_id = 1,
       lan_name = '国语',
       emo_id = 6,
       emo_name = '平静',
       rhy_id = 2,
       rhy_name = '缓和',
       is_check = 1,
       is_del = 0,
       is_rmd = 0,
       is_create = 0,
       is_org = 0,
                            ;";
    echo $query . "<br>";
    mysql_query($query) or die("插入失败");

    $rs->MoveNext();
}

?>

评论:(0)复制地址
发布:苗景云 | 分类:IT技术&设计 | Tags:mysql

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。