Hi:
In the OLD links, I found I had a need to update whole categories at a time. To that end, Alex wrote me a quick little perl script to look at CatLinks, and extract the Category Number, and insert that into a filed I added to Links (CategoryNum)
Anyway, I have not run that in a while, but I needed to this morning. It did not seem to run under the newest version of Links (I run 2.0.4)
Anyway, I was hoping someone might take a look at this really minor script and see if they can spot why it is not working. It does seem to run- it just does not insert anything into Links:CategoryNum....
# --------------------------------------------------------
my $link_db = $DB->table('Links');
my $catlink_db = $DB->table('CatLinks');
my $sth = $link_db->select ( ['ID'] );
while ( my ($id) = $sth->fetchrow_array ) {
my $sth2 = $catlink_db->select ( { LinkID => $id }, ['CategoryID'] );
my ($cid) = $sth2->fetchrow_array;
$link_db->update ( { CategoryNum => $cid }, { ID => $id } );
return;
}
print $IN->header();
print "Done Updating Links!\n\n";
}
1;
Thank you!
dave
dave
Big Cartoon DataBase
Big Comic Book DataBase
In the OLD links, I found I had a need to update whole categories at a time. To that end, Alex wrote me a quick little perl script to look at CatLinks, and extract the Category Number, and insert that into a filed I added to Links (CategoryNum)
Anyway, I have not run that in a while, but I needed to this morning. It did not seem to run under the newest version of Links (I run 2.0.4)
Anyway, I was hoping someone might take a look at this really minor script and see if they can spot why it is not working. It does seem to run- it just does not insert anything into Links:CategoryNum....
Code:
sub update_categories { # --------------------------------------------------------
my $link_db = $DB->table('Links');
my $catlink_db = $DB->table('CatLinks');
my $sth = $link_db->select ( ['ID'] );
while ( my ($id) = $sth->fetchrow_array ) {
my $sth2 = $catlink_db->select ( { LinkID => $id }, ['CategoryID'] );
my ($cid) = $sth2->fetchrow_array;
$link_db->update ( { CategoryNum => $cid }, { ID => $id } );
return;
}
print $IN->header();
print "Done Updating Links!\n\n";
}
1;
Thank you!
dave
dave
Big Cartoon DataBase
Big Comic Book DataBase