กรณีให้ main site อยู่ที่ global db ให้แก้ไข ดังนี้
1. db-config.php
1.1) บรรทัด ประมาณ 26 เพิ่ม
add_global_table('wp_blogs');
add_global_table('wp_blog_versions');
add_global_table('wp_commentmeta');
add_global_table('wp_comments');
add_global_table('wp_links');
add_global_table('wp_options');
add_global_table('wp_postmeta');
add_global_table('wp_posts');
add_global_table('wp_registration_log');
add_global_table('wp_signups');
add_global_table('wp_site');
add_global_table('wp_sitemeta');
add_global_table('wp_terms');
add_global_table('wp_term_relationships');
add_global_table('wp_term_taxonomy');
add_global_table('wp_usermeta');
add_global_table('wp_users');
1.2) บรรทัดที่ 16 กรณีที่ apache และ mysql อยู่เครื่องเดียวกัน สามารถใช้ add_dc_ip('127.0.0.', 'dc1'); แทนได้เลย
ไม่ต้องหา ip address ให้ใช้ ip loopback เลย (หรือทำตามตัวอย่าง work เหมือนกัน)
1.3) แนะนำให้ปิด vip db สำหรับ vip blog
//add_db_server('vip1', 'dc1',...
//add_vip_blog(1, 'vip1');
2. db.php
2.1 เพิ่ม code จาก
function get_blog_prefix( $blog_id = '' ) {
เป็น
function get_blog_prefix( $blog_id = '' ) {
//2t
if ($blog_id == 1)return $this->base_prefix;
2.2 และ เพิ่ม array ของ table commentmeta เข้าไป
จาก
var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
var $tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
เป็น
var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships','commentmeta');
var $tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships','commentmeta');
3 move-blogs.php
พวก die() error msg ไม่ show เพราะมันอยู่นอก tag <tr><td> จะดูต้อง view html src browser เอา
ให้แก้ ตามนี้ เอาไปทับชุดเดิมตั้งแต่ while loop เป็นต้นมา
while ($row = mysql_fetch_row($result)) {
//Here we find our blog id, hash it, and establish our new db names
echo "<tr><td colspan='4'>";
$blogid_get = explode("_", $row[0]);
$blogid = $blogid_get[1];
$md5_hash = md5($blogid);
$md5_dbprefix = dblookup(substr($md5_hash, 0, $newdbsize));
$this_blog_new_db = $newdb_prefix.$md5_dbprefix;
if ( !is_numeric($blogid) ) {
// this is a global table
$this_blog_new_db = $newdb_prefix."global";
}
/*
if ( $blogid == 1 ) {
$this_blog_new_db = $newdb_prefix."_home";
} elseif ( !is_numeric($blogid) ) {
// this is a global table
$this_blog_new_db = $newdb_prefix."_global";
}
*/
echo "</td></tr>";
$db = mysql_connect($dbhost, $dbuname, $dbpass) or die("<tr><td colspan='4'>Houston, we have a problem! <br />Database Error: ".mysql_error() . '</td></tr>');
mysql_select_db($this_blog_new_db, $db) or die("<tr><td colspan='4'>Houston, we have a problem! <br /><b> Looks like you need to create your new db's! If you're lucky, this link still works - <a href='http://calc.idtstudios.com/db.php'>click me</a> </b><br />Database Error: ".mysql_error() . '</td></tr>');
if( mysql_num_rows( mysql_query("SHOW TABLES LIKE '".$row[0]."'"))) { $tabletest = "<font color='green'>table in new db</font>"; } else { $tabletest = "table not in new db"; }
ลองดูครับ