Created
September 20, 2009 18:10
-
-
Save avdgaag/189868 to your computer and use it in GitHub Desktop.
When you are desperate and need to replace special characters across an entire wordpress database, here's one way of generating the right SQL statements to do that.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terms = { | |
'ë' => 'ë' | |
} | |
{ | |
'wp_posts' => %w{post_content post_title post_excerpt}, | |
'wp_comments' => %w{comment_author comment_author_url comment_content}, | |
'wp_terms' => %w{name}, | |
'wp_term_taxonomy' => %w{description} | |
}.each_pair do |table, columns| | |
columns.each do |column| | |
terms.each_pair do |search, replace| | |
puts "UPDATE #{table} SET #{column} = REPLACE (#{column}, '#{search}', '#{replace}');" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment