#!/usr/local/bin/perl # ================================================================== # Add 1 link to loads of categories use strict; use lib './'; use Links qw/$USER $IN $DB $CFG/; use CGI::Carp qw(fatalsToBrowser); local $SIG{__DIE__} = \&Links::fatal; Links::init('./'); # change this to the linkID of the record you wanna add to the cats my $link_id = 1234; print $IN->header; my $tbl = $DB->table('CatLinks'); # get rid of this one, cos we are gonna re-add it anyway $tbl->do_query(qq|DELETE FROM glinks_CatLinks WHERE LinkID = $link_id|) || die $GT::SQL::error; my $sth = $DB->table('Category')->select( ['ID'] ); while (my $id = $sth->fetchrow) { $DB->table('CatLinks')->do_query(qq|INSERT INTO glinks_CatLinks (CategoryID,LinkID) VALUES($id,$link_id)|) || die $GT::SQL::error; print qq|Added $link_id to $id
|; } print qq|Add done.... |;