Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-07-2005, 05:49 AM
David_R David_R is offline
 
Join Date: Mar 2005
Location: Los Angeles
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Replace old URL with new URL from entire Database

Hi,
We recently changed our forums url from www.olddomain.com to www.newdomain.com
We are using olddomain.com for more then 2 years and there are lots of posts, pms, internallly which contain those urls.

Is there a way to replace this from entire database ?
I know this can be done manually downloading the entire 800 MB database and removing those entries manually.
I am looking for an automated procedure.

we have following urls to be replace.
www.oldomain.com
olddomain.com
www.olddomain.com/forum
forum.olddomain.com

thank you.
Reply With Quote
  #2  
Old 03-07-2005, 09:52 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Run this SQL query:

[sql]UPDATE post SET pagetext = REPLACE(pagetext,'www.olddomain.com','www.newdomai n.com')[/sql]

For pm's this SQL query:

[sql]UPDATE pmtext SET message = REPLACE(message,'www.olddomain.com','www.newdomain .com')[/sql]

Note that query is very intensive, you should back-up your db before using it. It may very well screw up a lot of your posts/pms/entire database.

Remember to re-build the postcache if you use it, or the changes will not apper right away.
Reply With Quote
  #3  
Old 03-07-2005, 03:02 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh wow, I never knew about that MySQL function
Reply With Quote
  #4  
Old 03-08-2005, 04:48 AM
David_R David_R is offline
 
Join Date: Mar 2005
Location: Los Angeles
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thankyou very much for posting the easy solution here.
some questions.

Text to be replaced was our olddomain name, it used extensively across the database. In code tags, html tags, php tags, signatures, posts, pms, notes, every possible end-user area,

As suggested by you.
Code:
UPDATE post SET pagetext = REPLACE(pagetext,'www.olddomain.com','www.newdomain.com')
This will replace www.olddomain.com with www.newdomain.com ?

To execute other replacements:
olddomain.com
www.olddomain.com/forum
forum.olddomain.com
I assume I will only need to run 1 additional line:
Code:
UPDATE post SET pagetext = REPLACE(pagetext,'olddomain.com','newdomain.com')
?
Reply With Quote
  #5  
Old 03-08-2005, 12:02 PM
Guy G Guy G is offline
 
Join Date: Nov 2004
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by David_R
REPLACE(message,'www.olddomain.com','www.newdomain .com')
only that line needs to be changed.

this: "www.olddomain.com" is what u are looking for in the database
and this: "www.newdomain.com" is what being replaced....

change those to whatever u need.
Reply With Quote
  #6  
Old 03-09-2005, 04:09 PM
David_R David_R is offline
 
Join Date: Mar 2005
Location: Los Angeles
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

will this work properly for hyperlinks too ?
Reply With Quote
  #7  
Old 03-09-2005, 05:29 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It will run on any text.
Reply With Quote
  #8  
Old 04-03-2005, 03:57 AM
David_R David_R is offline
 
Join Date: Mar 2005
Location: Los Angeles
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad.loo
Run this SQL query:

[sql]UPDATE post SET pagetext = REPLACE(pagetext,'www.olddomain.com','www.newdomai n.com')[/sql]

For pm's this SQL query:

[sql]UPDATE pmtext SET message = REPLACE(message,'www.olddomain.com','www.newdomain .com')[/sql]

Note that query is very intensive, you should back-up your db before using it. It may very well screw up a lot of your posts/pms/entire database.

Remember to re-build the postcache if you use it, or the changes will not apper right away.
Posts and PMs Changed properly Thanks
Can you also list some more queries to change Signatures too

Changing homepage set under profile, and text content in the signatures
Reply With Quote
  #9  
Old 04-03-2005, 09:57 AM
Guy G Guy G is offline
 
Join Date: Nov 2004
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Signatures
[sql]
UPDATE usertextfield SET signature = REPLACE(signature,'www.olddomain.com','www.newdoma in.com')
[/sql]

Homepage
[sql]
UPDATE user SET homepage = REPLACE(homepage,'www.olddomain.com','www.newdomai n.com')
[/sql]
Reply With Quote
  #10  
Old 04-03-2005, 06:28 PM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wouldnt it be easier to use vb's replace feature.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:34 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03880 seconds
  • Memory Usage 2,255KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete