一次从ACESS数据库中把BLOG的日记搬迁到MYSQL下面……
<?php //mysql连接 require_once('../admin/mysql.php'); require_once('../admin/class/mysql.php'); $db = new DB_MySQL; $mysql = $db->connect($mysql_add,$mysql_user,$mysql_pass,$mysql_dbname);
/* $sql = "SELECT * FROM cn_blog"; $query = $db->query($sql); while($row = $db->fetch_array($query)) { echo $row['title']."<br/>"; } */
//excel连接 $conn = new com("adodb.connection"); //$connstr = "driver = {microsoft access driver(*.mdb)};dbq = ".realpath("jacking_data.mdb"); //$connstr = "driver = {microsoft access driver(*.mdb)};dbq = ".realpath("jacking_data.mdb"); $connstr = "provider = microsoft.jet.oledb.4.0;data source = ".realpath("jacking_data.mdb"); $conn->open($connstr); //连接数据库…… $sql = "SELECT * FROM AS_Log"; $rs = new com("adodb.recordset"); $rs->open($sql,$conn,1,3); while(!$rs->eof) { $Log_Title = $rs->fields("Log_Title"); $Log_Content = $rs->fields("Log_Content"); $Log_Time = $rs->fields("Log_Time"); //echo $Log_Title->value."<br/>"; //echo $Log_Content->value."<br/>"; $time1 = explode(' ',$Log_Time->value); $time2 = explode('/',$time1[0]); $time3 = explode(':',$time1[1]); $times = mktime($time3[0],$time3[1],$time3[2],$time2[1],$time2[2],$time2[0]); //$Log_Title = quotemeta($Log_Title); $Log_Title = addslashes($Log_Title); //$Log_Content = quotemeta($Log_Content); $Log_Content = addslashes($Log_Content); $Log_Content = str_replace('<font face="Verdana">','',$Log_Content); $Log_Content = str_replace('</font>','',$Log_Content); //$Log_Content = str_replace('"','\"',$Log_Content); //$Log_Content = str_replace(''','/'',$Log_Content);
//echo $time[0].$time2[0]."<br/>"; $sql = $db->query("SELECT * FROM cn_blog WHERE title = '$Log_Title'"); $countblog = $db->num_rows($sql); if($countblog < 1) { $m++; //echo $Log_Title."<br/>"; //if($m ==1 ){ // echo $Log_Content; //} $query = $db->query("INSERT INTO `cn_blog` (`date`, `title`, `content`, `trackbackurl`, `filename`, `author`, `classid`, `top`, `allow_remark`, `allow_face`, `draft`, `viewcount`) VALUES('$times','$Log_Title','$Log_Content','','','jacking', '3', '0', '1', '1', '0', '0')"); } $rs->movenext; } echo "总共更新了".$m."条记录"; ?>
|