From 60b1489fe53420212b89a87b89094f4fcb2b8082 Mon Sep 17 00:00:00 2001 From: wolfpac444 Date: Thu, 10 Apr 2003 04:05:18 +0000 Subject: [PATCH] Fixed bug #299 --- admin/currency.pl | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/admin/currency.pl b/admin/currency.pl index fb74712c63..98cf3abe73 100755 --- a/admin/currency.pl +++ b/admin/currency.pl @@ -113,12 +113,23 @@ if ($op eq 'add_form') { } elsif ($op eq 'add_validate') { $template->param(add_validate => 1); my $dbh = C4::Context->dbh; - my $query = "replace currency (currency,rate) values ("; - $query.= $dbh->quote($input->param('currency')).","; - $query.= $dbh->quote($input->param('rate')).")"; - my $sth=$dbh->prepare($query); - $sth->execute; - $sth->finish; + + my $check = $dbh->prepare("select * from currency where currency = ?"); + $check->execute($input->param('currency')); + if ( $check->fetchrow ) + { + my $sth = $dbh->prepare("UPDATE currency SET rate = ? WHERE currency = ?"); + $sth->execute($input->param('rate'),$input->param('currency')); + $sth->finish; + } + else + { + my $sth = $dbh->prepare("INSERT INTO currency (currency, rate) VALUES (?,?)"); + $sth->execute($input->param('currency'),$input->param('rate')); + $sth->finish; + } + + $check->finish; # END $OP eq ADD_VALIDATE ################## DELETE_CONFIRM ################################## # called by default form, used to confirm deletion of data in DB