Gossamer Forum
Home : Products : Gossamer Links : Discussions :

GT::SQL::table()->delete() Question...

Quote Reply
GT::SQL::table()->delete() Question...
Just a quick question. Currently I am using the following to delete a list of links that have LinkOwner => ALLPOSTERS.

Code:
my $sth = $DB->table('Links')->select( { LinkOwner => "ALLPOSTERS" } ) || die $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref) {
push(@delete_ids,$hit->{ID});
}

foreach (@delete_ids) {
$DB->table('Links')->delete( { ID => $_ } );
print "Deleting lsql_Links: $_ \n";
}

This seems *very* slow (even with 20,000 records). I've tried a couple of other approaches, of which none seem to work :(

Any ideas?

$DB->table('Links')->delete( { LinkOwner => "ALLPOSTERS" } );

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] GT::SQL::table()->delete() Question... In reply to
Managed to get around it by using;

Code:
my $poster_root_cat = $DB->table('Category')->select( ['ID'],{ AllPOSTERS_ID => 0 } )->fetchrow;
$DB->table('Category')->delete( { ID => $poster_root_cat } );

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!