PDA

View Full Version : Search and replace content in Subdreamer articles


mondala
09-07-2007, 01:44 PM
It is always a pain when you have data you need to mass update in the database.

Here is another example of how to search and replace with mysql. I use phpmyadmin myself in most cases to execute. See this wordpress example. (http://lorelle.wordpress.com/2005/12/01/search-and-replace-in-wordpress-mysql-database/)
If you don’t have to do this, then DO NOT DO THIS. MAKE BACKUPS if you want to try.

In Subdreamer I had an articles plugin filled strictly with content and links that I did not want the search engines to follow as it was strictly syndicated news and stuff that I wanted the rel="nofollow" tag added to.

Here is how I update the Subdreamer articles in one line. (updates ALL articles)

update sd_p2_news set article = replace(article,'<a href','<a rel="nofollow" href');More complex queries can also be built to do more advanced search and replaces.

Here is an example if you know you spell a word wrong all the time!!
update sd_p2_news set article = replace(article,'thier','their');GENERIC SYNTAX
UPDATE tablename SET fieldname = REPLACE(fieldname, 'badterm','goodterm');