Revision: 6289
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 14, 2008 19:40 by breakerjump
Initial Code
#!/usr/bin/ruby #require 'rubygems' require 'mysql' db = Mysql.real_connect("host", "username", "password", "database") ids = db.query("SELECT `ID` FROM `wp_posts` WHERE 1") ids.each_hash do |post| id = post['ID'] num = 0 comments = db.query("SELECT COUNT(1) FROM `wp_comments` WHERE `comment_post_ID`='#{id}' AND `comment_approved`='1';") comments.each {|x| num = x[0]} up = db.query("UPDATE `wp_posts` SET `comment_count`='#{num}' WHERE `ID`='#{id}';") end
Initial URL
Initial Description
Initial Title
WordPress Comment Recount via Ruby
Initial Tags
textmate, wordpress, ruby
Initial Language
Other