Home : Products : Gossamer Links : Discussions :

Products: Gossamer Links: Discussions: Re: [cdkrg] Bought Links with a bug, so help is needed: Edit Log

Here is the list of edits for this post
Re: [cdkrg] Bought Links with a bug, so help is needed
In case it helps i did notice that one change to the Tables.pm file Andy made was to add the following to the beginning:

use GT::SQL;


Edit:

I found the main difference in Andy's version and the original:

Original:




# -------------------------------------------------------------------
# Won't modify a record if the passed in timestamp is older then
# what's in the database.
#
my ($self, $keys, $set) = @_;

# first check to see if we even need to look up the orig timestamp.
my $auto = $self->time_check;
return 1 unless ($auto);
my $found = 0;
foreach (keys %$auto) {
exists $set->{$_} and ($found = 1); # should only be one timestamp.
}
return 1 unless ($found);

# if we got here, then we do a search on the record and compare timestamp.
my $pk = $self->{schema}->{pk};
my $cond = GT::SQL::Condition->new;
my @res;
foreach my $key (@$pk) {
$cond->add ($key, "=", $keys->{$key});
}
foreach my $tmstmp (keys %$auto) {
push @res, $tmstmp;
$cond->add ($tmstmp, ">", $set->{$tmstmp});
delete $set->{$tmstmp};
}
my $sth = $self->select ($cond, \@res) or return;
if ($sth->fetchrow_arrayref) {
return $self->error ('ALREADYCHANGED', 'WARN');
}
else {
return 1;
}
}
END_OF_SUB




Andy's




# -------------------------------------------------------------------
# Won't modify a record if the passed in timestamp is older then
# what's in the database.
#
my ($self, $keys, $set) = @_;

my $IN = new GT::CGI;

#if ($IN->param('do') =~ /modify/) { return 0; }

my $ID = $keys->{ID};
my $Timestmp = $set->{Timestmp};
my $DB = new GT::SQL '/home/a2kname/public_html/cgi-bin/links/admin/defs';

my $cond = GT::SQL::Condition->new(
'Timestmp', '=>' ,$Timestmp,
'ID','=',$ID
) or return $GT::SQL::error;
#$cond->bool('AND');
my $count = $DB->table('Links')->count($cond);

if (!$count) {
return 0;
} else {
return $self->error ("ALREADYCHANGED and ($count,$Timestmp,$ID)", 'WARN');
}

# first check to see if we even need to look up the orig timestamp.
# my $auto = $self->time_check;
# return 1 unless ($auto);
# my $found = 0;
# foreach (keys %$auto) {
# exists $set->{$_} and ($found = 1); # should only be one timestamp.
# }
# return 1 unless ($found);

# if we got here, then we do a search on the record and compare timestamp.
# my $pk = $self->{schema}->{pk};
# my $cond = GT::SQL::Condition->new;
# my @res;
# foreach my $key (@$pk) {
# $cond->add ($key, "=", $keys->{$key});
# }
# foreach my $tmstmp (keys %$auto) {
# push @res, $tmstmp;
# $cond->add ($tmstmp, ">", $set->{$tmstmp});
# delete $set->{$tmstmp};
# }
# my $sth = $self->select ($cond, \@res) or return;
# if ($sth->fetchrow_arrayref) {
# return $self->error ('ALREADYCHANGED', 'WARN');
# }
# else {
# return 1;
# }
}
END_OF_SUB

cdkrg

Able2Know :: Ajooja Directory

Last edited by:

cdkrg: Oct 10, 2003, 6:24 PM

Edit Log: