develooper Front page | perl.dbi.users | Postings from March 2005

How many lines deleted?

Thread Next
From:
Gavin Henry
Date:
March 27, 2005 08:58
Subject:
How many lines deleted?
Message ID:
200503271756.53820.ghenry@suretecsystems.com
Dear all,

I have a simple program to delete spam comments from Wordpress. How do I 
return the number of comments deleted?

Current code:

#!/usr/bin/perl

use warnings;
use strict;
use DBI;

my $db = 'DBI:mysql:changed_for_email:localhost';
my $username = 'changed_for_email';
my $pass = 'changed_for_email';

my $dbh = DBI->connect($db, $username, $pass)
    or die "Couldn't connect to database: " . DBI->errstr;
my $sql = qq{ DELETE FROM wp_comments WHERE comment_approved='0' };

$dbh->do($sql);
$dbh->disconnect();

print "All comments deleted sucessfully.\n";


Thanks.

-- 
Kind Regards,
Gavin Henry.

Open Source. Open Solutions(tm).

http://www.suretecsystems.com/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About