4 my $dbh = DBI->connect('DBI:mysql:copyrighteous:localhost', 'mako')
5 or die "Cannot connect: " . $DBI::errstr;
8 $sql = qq`SELECT comment_ID, comment_author from wp_comments`;
9 $sth = $dbh->prepare($sql) or die "Cannot prepare: " . $dbh->errstr();
10 $sth->execute() or die "Cannot execute: " . $sth->errstr();
14 while(@row = $sth->fetchrow_array()) {
16 push(@fields, \@record);
20 # now process the fields
25 foreach $line (@fields) {
27 if (@$line[1] =~ /^.*\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (.*)$/) {
31 elsif (@$line[1] =~ /^\d+\.\d+\.\d+\.\d+ (.*)$/) {
37 $comment_id = @$line[0];
38 #print "Old: ", @$line[1], "\n";
39 print "Updating: ", $comment_id, " ", $new_username, "\n";
41 $sql = qq`UPDATE wp_comments SET comment_author = "$new_username" WHERE comment_ID = $comment_id`;
42 $sth = $dbh->prepare($sql) or die "Cannot prepare: " .
44 $sth->execute() or die "Cannot execute: " . $sth->errstr();
46 #print "row $i - id is @$line[0], name is @$line[1]\n";