wordpress-3.0.1 ทำ multidb แล้วขึ้นหน้าขาว ๆ ครับใครก็ใด้ช่วยผมที

เริ่มโดย คนเดินทางไกล, 02 สิงหาคม 2010, 19:05:01

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

คนเดินทางไกล

คือ ทำ multi site ผ่านแล้ว จะทำ multidb ทำตามเว็บนี้ครับ
http://www.nichecyber.com/read.php?tid=356

แล้วมันขึ้นหน้าขาวจั๊วเลยครับ มันก็ก๊อป db ไปครบหมดนะครับ
นี่ครับhttp://www.centerpricegoods.com/
ขอบพระคุณอย่างสูงล่วงหน้าครับ :wanwan017: :wanwan017:

ไฟล์ error มันขึ้นมายังงี้
PHP Fatal error:  Call to undefined method wpdb::tables() in /home/xxxxx/public_html/wp-includes/functions.php on line 1839

คนเดินทางไกล


g-ji

กรรม ตอบผิดกระทู้  :o :wanwan031: มันเด้งมาอันนี้ได้ไงหว่า

คนเดินทางไกล


lopata

กรณีให้ 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"; }

ลองดูครับ

lopata

จากนั้นลองไล่ดูครับ ว่ามันกระจาย table ถูก db หรือไม่ ผ่าน phpmyadmin
วิธีคร่าวๆ
   $md5_hash = md5($blogid);
   $md5_dbprefix = substr($md5_hash, 0, $newdbsize);

code ข้างบนเป็นของ move-blogs.php เพราะมันต้องสัมพันธ์กับ db.php ตรง md5() เพื่อเป็น selector db
เช่น กรณี 256 db => $newdbsize = 2
blogid = 2 => c81e728d9d4c2f636f067f89cc14862c , dbprefix = c8
blogid = 3 => eccbc87e4b5ce2fe28308fd9f2a7baf3 , dbprefix = ec
และ blogid = 1, db ต้องเป็น global นะ

ลองดูนะ
ไปแล้วครับ

yyy

ตอนที่ทำ เคยมีปัญหากับหน้าหลักของเว็บเหมือนกัน
แต่ไม่แน่ใจว่าจะเป็นปัญหาเดียวกันหรือเปล่านะครับ

จากกระทู้นี้ http://www.thaiseoboard.com/index.php?topic=105484.0
เคยไปถามเอาไว้ มีผู้ใจดีเข้ามาตอบ 2 ท่าน

ตามนี้ครับ
1.
อ้างถึงจาก: Doytao ใน 26 กรกฎาคม 2010, 11:56:00
ลองแก้ db-config.php ของ MultiDB

บรรทัดที่ 62 ใส่ # หน้า add_vip_blog(1, 'vip1');
2.
อ้างถึงจาก: esguitar ใน 26 กรกฎาคม 2010, 17:46:25
หุหุ มาบอกไม่ทันว่าให้ย้าย db ของโดเมนหลักไปไว้ใน vip

แต่ถ้าทำแบบที่คุณ Doytao บอกแล้วได้ ผมก็ขอเอาไปใช้ด้วยนะครับ  :wanwan020:

ผมแก้แบบแรกก็ใช้ได้เลย

ลองดูนะครับ

คนเดินทางไกล

อ้างถึงจาก: 2t ใน 03 สิงหาคม 2010, 00:20:28
กรณีให้ 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"; }

ลองดูครับ
ขอบคุณมากครับจัดไป +1