前提条件
- 首先安装好 solo,创建用户保证可以访问。
- 确保 wordpress 数据库与 solo 数据库可以同时访问。
执行脚本
以 solo 数据库为访问库,wordpress 数据库被我命名为 wp 了,如果命名不一致,将 wp 改为你的 wordpress 数据库名即可。
导入文章表数据
INSERT INTO b3_solo_article
SELECT
posts.id AS oId
,posts.post_title AS articleTitle
,'' AS articleAbstract
,'' AS articleAbstractText
,(SELECT
group_concat(terms.name)
FROM
wp.wp_terms terms,
wp.wp_term_relationships rs
WHERE
terms.term_id = rs.term_taxonomy_id
AND rs.object_id = posts.ID
GROUP BY rs.object_id ) AS articleTags
,(select oId from b3_solo_user LIMIT 1) AS articleAuthorId
,0 AS articleCommentCount
,0 AS articleViewCount
,posts.post_content AS articleContent
,concat('/articles/',year(posts.post_date),'/',LPAD(month(posts.post_date), 2, 0),'/',LPAD(DAY(posts.post_date),2,0),'/',posts.id,'.html') AS articlePermalink
,0 AS articlePutTop
,concat(unix_timestamp(posts.post_date),'000') AS articleCreated
,concat(unix_timestamp(posts.post_date),'000') AS articleUpdated
,RAND() AS articleRandomDouble
,1 AS articleSignId
,1 AS articleCommentable
,'' AS articleViewPwd
,'https://b3logfile.com/bing/20180320.jpg?imageView2/1/w/1280/h/720/interlace/1/q/100' AS articleImg1URL
,(CASE WHEN posts.post_status = 'publish' THEN 0 ELSE 1 END) AS articleStatus
FROM
wp.wp_posts posts
WHERE posts.post_parent = 0
AND posts.post_type != 'nav_menu_item'
AND posts.post_type != 'page'
导入存档日期表数据
INSERT INTO b3_solo_archivedate
SELECT DISTINCT
concat(
unix_timestamp(
str_to_date(
concat(
YEAR (posts.post_date),
'-',
LPAD(MONTH(posts.post_date), 2, 0),
'-01'
),
'%Y-%m-%d'
)
),
'000'
) AS oId
,concat(
unix_timestamp(
str_to_date(
concat(
YEAR (posts.post_date),
'-',
LPAD(MONTH(posts.post_date), 2, 0),
'-01'
),
'%Y-%m-%d'
)
),
'000'
) AS archiveDate_oId
FROM
wp.wp_posts posts
WHERE
posts.post_parent = 0
AND posts.post_type != 'nav_menu_item'
AND posts.post_type != 'page'
GROUP BY concat(
unix_timestamp(
str_to_date(
concat(
YEAR (posts.post_date),
'-',
LPAD(MONTH(posts.post_date), 2, 0),
'-01'
),
'%Y-%m-%d'
)
),
'000'
)
导入存档-文章关联表数据
INSERT INTO b3_solo_archivedate_article
SELECT
posts.id AS oId,
concat(
unix_timestamp(
str_to_date(
concat(
YEAR (posts.post_date),
'-',
LPAD(MONTH(posts.post_date), 2, 0),
'-01'
),
'%Y-%m-%d'
)
),
'000'
) AS archiveDate_oId,
posts.id AS article_oId
FROM
wp.wp_posts posts
WHERE
posts.post_parent = 0
AND posts.post_type != 'nav_menu_item'
AND posts.post_type != 'page'
导入标签表数据
INSERT INTO b3_solo_tag
SELECT
term_id AS oId,
name AS tagTitle
FROM
wp.wp_terms
导入标签-文章关联表数据
INSERT INTO b3_solo_tag_article
SELECT
CONCAT(object_id,term_taxonomy_id) AS oId,
object_id AS article_oId,
term_taxonomy_id AS tag_oId
FROM
wp.wp_term_relationships
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于