From 066dd7175f729a2467e6d8e0bf8e81591fe8ec3d Mon Sep 17 00:00:00 2001 From: tonnesen Date: Tue, 17 Sep 2002 22:30:36 +0000 Subject: [PATCH] Found the real culprit. The printers table did not have a primary key so replace was not working. --- admin/printers.pl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/admin/printers.pl b/admin/printers.pl index 1055a3de5e..eeb5b355bb 100755 --- a/admin/printers.pl +++ b/admin/printers.pl @@ -156,17 +156,13 @@ printend # called by add_form, used to insert/modify data in DB } elsif ($op eq 'add_validate') { my $dbh=C4Connect; - my $sth=$dbh->prepare("select * from printers where printername=?"); - $sth->execute($input->param('printername')); - if ($sth->rows) { - my $sti=$dbh->prepare("update printers set printqueue=?,printtype=? where printername=?"); - $sti->execute($input->param('printqueue'), $input->param('printtype'), $input->param('printername')); - $sti->finish; - } else { - my $sti=$dbh->prepare("insert into printers (printqueue,printtype,printername) values (?,?,?)"); - $sti->execute($input->param('printqueue'), $input->param('printtype'), $input->param('printername')); - $sti->finish; - } + my $query = "replace printers (printername,printqueue,printtype) values ("; + $query.= $dbh->quote($input->param('printername')).","; + $query.= $dbh->quote($input->param('printqueue')).","; + $query.= $dbh->quote($input->param('printtype')).")"; + my $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; print "data recorded"; print "
"; print ""; -- 2.39.5