Skip to content

Instantly share code, notes, and snippets.

@avdgaag
Created September 20, 2009 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avdgaag/189868 to your computer and use it in GitHub Desktop.
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.
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