ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์CMS & Free Scriptwordpress-3.0.1 ทำ multidb แล้วขึ้นหน้าขาว ๆ ครับใครก็ใด้ช่วยผมที
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: wordpress-3.0.1 ทำ multidb แล้วขึ้นหน้าขาว ๆ ครับใครก็ใด้ช่วยผมที  (อ่าน 1376 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
คนเดินทางไกล
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 122
ออฟไลน์ ออฟไลน์

กระทู้: 1,014



ดูรายละเอียด เว็บไซต์
« เมื่อ: 02 สิงหาคม 2010, 19:05:01 »

คือ ทำ 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
« แก้ไขครั้งสุดท้าย: 02 สิงหาคม 2010, 19:19:26 โดย คนเดินทางไกล » บันทึกการเข้า
คนเดินทางไกล
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 122
ออฟไลน์ ออฟไลน์

กระทู้: 1,014



ดูรายละเอียด เว็บไซต์
« ตอบ #1 เมื่อ: 02 สิงหาคม 2010, 22:36:22 »

ดันยามดึก  wanwan014
บันทึกการเข้า
g-ji
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 231
ออฟไลน์ ออฟไลน์

กระทู้: 3,254



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 02 สิงหาคม 2010, 22:59:55 »

กรรม ตอบผิดกระทู้  Shocked wanwan031 มันเด้งมาอันนี้ได้ไงหว่า
« แก้ไขครั้งสุดท้าย: 02 สิงหาคม 2010, 23:00:48 โดย g-ji » บันทึกการเข้า

คนเดินทางไกล
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 122
ออฟไลน์ ออฟไลน์

กระทู้: 1,014



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 03 สิงหาคม 2010, 00:02:58 »

กรรม ตอบผิดกระทู้  Shocked wanwan031 มันเด้งมาอันนี้ได้ไงหว่า
Huh? Huh?
บันทึกการเข้า
lopata
ก๊วนเสียว
*

พลังน้ำใจ: 16
ออฟไลน์ ออฟไลน์

กระทู้: 324



ดูรายละเอียด
« ตอบ #4 เมื่อ: 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"; }
ลองดูครับ
« แก้ไขครั้งสุดท้าย: 03 สิงหาคม 2010, 00:37:22 โดย 2t » บันทึกการเข้า
lopata
ก๊วนเสียว
*

พลังน้ำใจ: 16
ออฟไลน์ ออฟไลน์

กระทู้: 324



ดูรายละเอียด
« ตอบ #5 เมื่อ: 03 สิงหาคม 2010, 00:27:04 »

จากนั้นลองไล่ดูครับ ว่ามันกระจาย 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 นะ

ลองดูนะ
ไปแล้วครับ
« แก้ไขครั้งสุดท้าย: 03 สิงหาคม 2010, 00:30:40 โดย 2t » บันทึกการเข้า
yyy
ก๊วนเสียว
*

พลังน้ำใจ: 14
ออฟไลน์ ออฟไลน์

กระทู้: 204



ดูรายละเอียด
« ตอบ #6 เมื่อ: 03 สิงหาคม 2010, 00:30:11 »

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

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

ตามนี้ครับ
1.
ลองแก้ db-config.php ของ MultiDB

บรรทัดที่ 62 ใส่ # หน้า add_vip_blog(1, 'vip1');

2.
หุหุ มาบอกไม่ทันว่าให้ย้าย db ของโดเมนหลักไปไว้ใน vip

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


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

ลองดูนะครับ
บันทึกการเข้า
คนเดินทางไกล
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 122
ออฟไลน์ ออฟไลน์

กระทู้: 1,014



ดูรายละเอียด เว็บไซต์
« ตอบ #7 เมื่อ: 03 สิงหาคม 2010, 02:07:49 »

กรณีให้ 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
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์