vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Replace old URL with new URL from entire Database (https://vborg.vbsupport.ru/showthread.php?t=77648)

David_R 03-07-2005 05:49 AM

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.

Brad 03-07-2005 09:52 AM

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.

Dean C 03-07-2005 03:02 PM

Oh wow, I never knew about that MySQL function :)

David_R 03-08-2005 04:48 AM

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')
?

Guy G 03-08-2005 12:02 PM

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.

David_R 03-09-2005 04:09 PM

will this work properly for hyperlinks too ?

Marco van Herwaarden 03-09-2005 05:29 PM

It will run on any text.

David_R 04-03-2005 03:57 AM

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

Guy G 04-03-2005 09:57 AM

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]

Reeve of shinra 04-03-2005 06:28 PM

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


All times are GMT. The time now is 10:54 PM.

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.01052 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete