$dbs = array("bsblogs"=>array("http://the.src.site.dns/pathto/","http://the.new.site.dns/","the.src.site.dns","the.new.site.dns","/pathto/","/"));
foreach ( $dbs as $dbname => $fixv ){
$fix_wp_db->setQuery("USE the_database_name;");
$fix_wp_db->query();
$fix_wp_db->setQuery("SHOW TABLES;");
$tables = $fix_wp_db->loadObjectList();
//print_r($fix_wp_db);
foreach($tables as $tb){
if( preg_match('/[0-9+]_options$/',$tb->Tables_in_the_database_name) ){
echo $tb->Tables_in_the_database_name."
";
$fix_wp_db->setQuery("UPDATE $tb->Tables_in_the_database_name SET option_value = REPLACE( `option_value` , '$fixv[0]', '$fixv[1]' ) ;");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}
if( preg_match('/[0-9+]_posts$/',$tb->Tables_in_the_database_name) ){
echo $tb->Tables_in_the_database_name."
";
$fix_wp_db->setQuery("UPDATE $tb->Tables_in_the_database_name SET post_content = REPLACE( `post_content` , '$fixv[0]', '$fixv[1]' ) ;");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}
}
$fix_wp_db->setQuery("UPDATE wp_site SET domain = REPLACE( `domain` , '$fixv[2]', '$fixv[3]' ) , path = REPLACE( `path` , '$fixv[4]', '$fixv[5]' );");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
$fix_wp_db->setQuery("UPDATE wp_blogs SET domain = REPLACE( `domain` , '$fixv[2]', '$fixv[3]' ) , path = REPLACE( `path` , '$fixv[4]', '$fixv[5]' );");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}
.htaccess 也要改
沒有留言:
張貼留言