Skip to content
Create a gist now

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
require 'digest/md5'
db = => '', :port => 3307, :username => 'blog', :password => '123456', :database => 'wpblog_global')
db.query('SELECT `blog_id` as blog FROM wpblog_global.wp_blogs').each do |row|
db.query("INSERT INTO `wpblog_global`.`all_posts`(`blog_id`, `user_id`, `post_id`, `status`, `title`, `excerpt`, `content`, `name`, `date`, `modified`, `comment_status`, `comment_count`, `post_type`)SELECT #{row['blog'].to_s}, `post_author`, `ID`,`post_status`, `post_title`, `post_excerpt`, `post_content`, `post_name`, `post_date`, `post_modified`, `comment_status`, `comment_count`, `post_type` FROM wpblog_#{Digest::MD5.hexdigest(row['blog'].to_s)[0, 3]}.wp_#{row['blog'].to_s}_posts;")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.