Created
March 4, 2011 16:37
-
-
Save ikennaokpala/854969 to your computer and use it in GitHub Desktop.
UPDATE_COUNT_RUBY_STYLE
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
require 'rubygems' | |
require 'mysql' | |
mysql = Mysql.real_connect("localhost", "root", "pass", "db") | |
results = mysql.query("select wp_term_taxonomy.term_taxonomy_id as taxo_id, count(*) as count from wp_term_taxonomy | |
left join wp_term_relationships on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id | |
where (wp_term_taxonomy.parent = 6 or wp_term_taxonomy.term_id = 6) group by term_id;") | |
results.each { |e| | |
mysql.query("UPDATE WP_TERM_TAXONOMY SET COUNT = #{e[1]} WHERE WP_TERM_TAXONOMY.TERM_TAXONOMY_ID = #{e[0]};") | |
} | |
# results.each { |e| | |
# puts e[0] +" , "+ e[1] | |
# | |
# } | |
mysql.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment