Gossamer Forum
Home : Products : Gossamer Links : Discussions :

help wanted: add links with a bulk routine

Quote Reply
help wanted: add links with a bulk routine
Hi,

I am updating the Links table from another table and I am having some troubles there.

I changed my ID and LinksID to varchar but the problem already occured before.
I use:

Code:
foreach .. {

my @CategoryID = ('71007');
$add->{"CatLinks.LinkID"} = $add->{ID}; # $add->{ID} is predifined and unique
$add->{"CatLinks.CategoryID"} = \@CategoryID;
$added = $db->{Links}->add($add);
!$added ? ($error .= join('', map "$_ $add->{MPID}\n", $db->{Links}->error)) : print "$add->{ID} added\n";
}

This way only Links are added, no CatLinks.
When I add

Code:
$sth->{CatLinks} = $db->{CatLinks}->prepare("INSERT INTO glinks_CatLinks (LinkID, CategoryID) VALUES (?, ?)");
$sth->{CatLinks}->execute($add->{ID},71007)

It works

removing

Code:
my @CategoryID = ('71007');
$add->{"CatLinks.LinkID"} = $add->{ID}; # $add->{ID} is predifined and unique
$add->{"CatLinks.CategoryID"} = \@CategoryID;

leads to an error:
Quote:
You did not specify a category for this link.

If I turn on debug there is a SQL-Command for adding the Link record but not the CatLink record.

I am a little confused.

Thanks for help

n || i || k || o

Last edited by:

el noe: Jun 19, 2007, 9:14 AM
Quote Reply
Re: [el noe] help wanted: add links with a bulk routine In reply to
Hmm, it looks like it only works with auto_increment and probably I have deactivated this before setting the ID properties to varchar.
In GT::SQL::Table it says return ID if it is an auto incremental value.

I guess the ID for CatLinks must come from this routine and so I only have the option with insert left. :(