From de3a628903d5f473a677e2550276ed0e8e3e01cf Mon Sep 17 00:00:00 2001 From: slef Date: Mon, 5 Jan 2004 17:53:36 +0000 Subject: [PATCH] DBI call fix for bug 662 --- admin/marctagstructure.pl | 21 ++++++++------------- admin/stopwords.pl | 21 +++++++++------------ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index c6a1ad95d2..2564e85e4b 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -34,25 +34,20 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $query="Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where (tagfield >= $data[0]) order by tagfield"; - my $sth=$dbh->prepare($query); - $sth->execute; + my $sth=$dbh->prepare("Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where (tagfield >= ?) order by tagfield"); + $sth->execute($data[0]); my @results; - my $cnt=0; while (my $data=$sth->fetchrow_hashref){ push(@results,$data); - $cnt ++; } # $sth->execute; $sth->finish; - return ($cnt,\@results); + return (scalar(@results),\@results); } my $input = new CGI; my $searchfield=$input->param('searchfield'); $searchfield=0 unless $searchfield; -my $pkfield="tagfield"; -my $reqsel="select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where $pkfield='$searchfield'"; my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/marctagstructure.pl"; @@ -84,8 +79,8 @@ if ($op eq 'add_form') { #---- if primkey exists, it's a modify action, so read values to modify... my $data; if ($searchfield) { - my $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where $pkfield='$searchfield'"); - $sth->execute; + my $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=?"); + $sth->execute($searchfield); $data=$sth->fetchrow_hashref; $sth->finish; } @@ -145,8 +140,8 @@ if ($op eq 'add_form') { # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare($reqsel); - $sth->execute; + my $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=?"); + $sth->execute($searchfield); my $data=$sth->fetchrow_hashref; $sth->finish; $template->param(liblibrarian => $data->{'liblibrarian'}, @@ -158,7 +153,7 @@ if ($op eq 'add_form') { } elsif ($op eq 'delete_confirmed') { my $dbh = C4::Context->dbh; unless (C4::Context->config('demo') eq 1) { - $dbh->do("delete from marc_tag_structure where $pkfield='$searchfield'"); + $dbh->do("delete from marc_tag_structure where tagfield='$searchfield'"); $dbh->do("delete from marc_subfield_structure where tagfield='$searchfield'"); } # END $OP eq DELETE_CONFIRMED diff --git a/admin/stopwords.pl b/admin/stopwords.pl index 10b2833eb2..75b45d838b 100755 --- a/admin/stopwords.pl +++ b/admin/stopwords.pl @@ -52,9 +52,9 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $query="Select word from stopwords where (word like \"$data[0]%\") order by word"; - my $sth=$dbh->prepare($query); - $sth->execute; + my $query=""; + my $sth=$dbh->prepare("Select word from stopwords where (word like ?) order by word"); + $sth->execute("$data[0]%"); my @results; my $cnt=0; while (my $data=$sth->fetchrow_hashref){ @@ -68,9 +68,6 @@ sub StringSearch { my $input = new CGI; my $searchfield=$input->param('searchfield'); -my $pkfield="word"; -my $reqsel="select word from stopwords where $pkfield='$searchfield'"; -my $reqdel="delete from stopwords where $pkfield='$searchfield'"; my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/stopwords.pl"; @@ -99,8 +96,8 @@ if ($op eq 'add_form') { my $data; if ($searchfield) { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select word from stopwords where word='$searchfield'"); - $sth->execute; + my $sth=$dbh->prepare("select word from stopwords where word=?"); + $sth->execute($searchfield); $data=$sth->fetchrow_hashref; $sth->finish; } @@ -123,8 +120,8 @@ if ($op eq 'add_form') { } elsif ($op eq 'delete_confirm') { $template->param(delete_confirm => 1); my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare($reqsel); - $sth->execute; + my $sth=$dbh->prepare("select word from stopwords where word=?"); + $sth->execute($searchfield); my $data=$sth->fetchrow_hashref; $sth->finish; # END $OP eq DELETE_CONFIRM @@ -133,8 +130,8 @@ if ($op eq 'add_form') { } elsif ($op eq 'delete_confirmed') { $template->param(delete_confirmed => 1); my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare($reqdel); - $sth->execute; + my $sth=$dbh->prepare("delete from stopwords where word=?"); + $sth->execute($searchfield); $sth->finish; # END $OP eq DELETE_CONFIRMED ################## DEFAULT ################################## -- 2.39.5