Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

delete all links belonging to linkowner

Home: Plugins Support - Paid: Data_Import:

 

 


scottish
User

Karma: -0 / +0

Sep 24, 2005, 4:48 AM

Post #1 of 4 (2730 views)
Shortcut

Send scottish a wink
delete all links belonging to linkowner Can't Post

Looking to have a simple way to delete all links belonging to a Linkowner.

Could you possibly produce a minimal import script where I can change the Linkowner (hardcoding) to whoever I want and therefore delete all links by running the script- or is there a mySQL command I can use?

Still trying to catch up! Thanks


Andy
Enthusiast

Karma: -1 / +7


Sep 26, 2005, 12:23 AM

Post #2 of 4 (2717 views)
Shortcut

Send Andy a wink
Re: [scottish] delete all links belonging to linkowner [In reply to] Can't Post

Hi,

Try this;


Code
#!/usr/local/bin/perl 

use strict;
use lib './';
use Links qw/$IN $DB $CFG/;
use GT::SQL;
use GT::SQL::Condition;
use CGI::Carp qw(fatalsToBrowser);

local $SIG{__DIE__} = \&Links::fatal;

Links::init('./');

my $user_to_delete = 'testing';

my $sth = $DB->table('Links')->select( { LinkOwner => $user_to_delete } ) || die $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
print qq{Deleting $hit->{ID} \n };
$DB->table('Links')->delete( { ID => $hit->{ID} } );
}


Save this as remove.cgi, and upload to your /admin folder.

Just run with;

perl remove.cgi

Then watch it work <G>

Cheers
Andy
Programmer/Designer/LinksSQL Freak Cool

http://www.ultranerds.com
http://www.imagesql.com



scottish
User

Karma: -0 / +0

Sep 27, 2005, 2:57 AM

Post #3 of 4 (2713 views)
Shortcut

Send scottish a wink
Re: [Andy] delete all links belonging to linkowner [In reply to] Can't Post

Thanks Andy, solved the problem and will no doubt be useful in lots of future occurences.

Would if be worth combining this with the plugin so it appears in the menu?


Andy
Enthusiast

Karma: -1 / +7


Sep 27, 2005, 3:20 AM

Post #4 of 4 (2711 views)
Shortcut

Send Andy a wink
Re: [scottish] delete all links belonging to linkowner [In reply to] Can't Post

Hi,

Glad it worked :)


Quote
Would if be worth combining this with the plugin so it appears in the menu?


Indeed. I'll try and add that in tonight =)

Cheers
Andy
Programmer/Designer/LinksSQL Freak Cool

http://www.ultranerds.com
http://www.imagesql.com

 
 
 


Search for (options) Powered by Gossamer Forum v.1.2.4