花了两个小时把以前JRblog上的文章全转移到wordpress上来了。。。好久不写PHP再写起来真手生
不过现在总算有75篇文章了,哇哈哈,向100篇文章迈进!
为了撑点字数干脆把代码的主体发上来吧。。
- <?php
- /*
- boblog_blogs:
- blogid
- title
- pubtime
- content
- wp_posts:
- ID
- post_author=2
- post_date:2007-05-03 22:29:27
- post_date_gmt:前者-8
- post_content
- post_title
- post_catagory=0
- post_status=publish
- comment_status=open
- ping_status=open
- post_name=post_title的encoded版
- post_modified=post_date
- post_modified_gmt=post_date_gmt
- guid=http://www.jerryhong.com/2007/05/19/post_name
- comment_count=0
- */
- include_once('jmysql.php');
- $result=db_query('select title, pubtime, content from boblog_blogs');
- foreach($result as $tuple)
- //$tuple=$result[0];
- {
- $post_date=date('Y-m-d h:i:s', $tuple[pubtime]);
- $post_name=addslashes(urlencode($tuple[title]));
- $guid="http://www.jerryhong.com/".date('Y',$tuple[pubtime]).'/'.date('m',$tuple[pubtime]).'/'.date('d',$tuple[pubtime]).'/'.$post_name;
- $tuple[content]=addslashes($tuple[content]);
- $tuple[title]=addslashes($tuple[title]);
- $sql="INSERT INTO `wp_posts` ( `ID` , `post_author` , `post_date` , `post_date_gmt` , `post_content` , `post_title` , `post_category` , `post_excerpt` , `post_status` , `comment_status` , `ping_status` , `post_password` , `post_name` , `to_ping` , `pinged` , `post_modified` , `post_modified_gmt` , `post_content_filtered` , `post_parent` , `guid` , `menu_order` , `post_type` , `post_mime_type` , `comment_count` ) VALUES ( NULL , '2', '$post_date', '$post_date', '$tuple[content]', '$tuple[title]', '0', '', 'publish', 'open', 'open', '', '$post_name', '', '', '$post_date', '$post_date', '', '$guid', '', '0', 'post', '', '0')";
- echo ($sql);
- db_query($sql);
- }






0 Responses to “转移完成”
Leave a Reply