您可以为此编写一个脚本,下面是我最近用Perl编写的内容:
首先检查sql语句以检查术语是否已经存在,如果不存在,则插入它:准备好的语句:
my $wts = $dbh->prepare(
"SELECT term_id FROM $tb_wp_terms WHERE name = ?")
or die "Couldn\'t prepare statement: " . dbh->errstr;
my $wti = $dbh->prepare(
"INSERT INTO $tb_wp_terms
(name, slug) VALUES (?,?)")
or die "Couldn\'t prepare statement: " . dbh->errstr;
然后输入术语分类法条目:准备好的语句:
my $wtts = $dbh->prepare(
"SELECT term_taxonomy_id FROM $tb_wp_term_taxonomy WHERE term_id = ?
AND taxonomy = \'".$config{\'wordpress.taxonomy_type\'}."\'")
or die "Couldn\'t prepare statement: " . dbh->errstr;
my $wtti = $dbh->prepare(
"INSERT INTO $tb_wp_term_taxonomy
(term_id, taxonomy, count) VALUES (?,?,1)")
or die "Couldn\'t prepare statement: " . dbh->errstr;
my $wtts_count = $dbh->prepare(
"SELECT count FROM $tb_wp_term_taxonomy WHERE term_taxonomy_id = ? AND taxonomy =
\'".$config{\'wordpress.taxonomy_type\'}."\'")
or die "Couldn\'t prepare statement: " . dbh->errstr;
my $wtti_count = $dbh->prepare(
"UPDATE $tb_wp_term_taxonomy
SET count = ?
WHERE term_taxonomy_id = ?
")
or die "Couldn\'t prepare statement: " . dbh->errstr;
并使用上面的查询和一些代码(您需要检查已经有一些类别的博客)。
对于MU,只有>1的博客才能在其表名中获得博客id:
my $tb_blogid = "";
if ( $config{\'wordpress.wp_mu_blog_id\'} > 1 )
{
$tb_blogid = "_" . $config{\'wordpress.wp_mu_blog_id\'};
}
my $tb_posts = $config{\'wordpress.prefix\'} . $tb_blogid . "_posts";
my $tb_wp_terms = $config{\'wordpress.prefix\'} . $tb_blogid . "_terms";
my $tb_wp_term_taxonomy = $config{\'wordpress.prefix\'} . $tb_blogid .
"_term_taxonomy";
my $tb_wp_terms_relationships = $config{\'wordpress.prefix\'} . $tb_blogid .
"_term_relationships";
所以只要循环一下就可以了。