X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=admin%2Fauthorised_values.pl;h=528202289e40acb128b8d3359f4249a62b924377;hb=5f2e1ba7b14b226cbe23438116d77be710dd88b0;hp=c26f3a9ec5cb4b50bfe4827249796b2664ea8f25;hpb=3b5aa120d71ebc7c3db7fb2177d360df03d5ed35;p=koha_fer diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index c26f3a9ec5..528202289e 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -27,7 +27,7 @@ use C4::Koha; use C4::Output; -sub AuthorizedValuesForCategory ($) { +sub AuthorizedValuesForCategory { my ($searchstring) = shift or return; my $dbh = C4::Context->dbh; $searchstring=~ s/\'/\\\'/g; @@ -104,15 +104,14 @@ if ($op eq 'add_form') { my $duplicate_entry = 0; if ( $id ) { # Update - my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id='$id' "); - $sth->execute(); + my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id = ? "); + $sth->execute($id); my ($category, $authorised_value) = $sth->fetchrow_array(); if ( $authorised_value ne $new_authorised_value ) { my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . - "WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' and id<>$id"); - $sth->execute(); + "WHERE category = ? AND authorised_value = ? and id <> ? "); + $sth->execute($new_category, $new_authorised_value, $id); ($duplicate_entry) = $sth->fetchrow_array(); - warn "**** duplicate_entry = $duplicate_entry"; } unless ( $duplicate_entry ) { my $sth=$dbh->prepare( 'UPDATE authorised_values @@ -133,8 +132,8 @@ if ($op eq 'add_form') { } else { # Insert my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . - "WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' "); - $sth->execute(); + "WHERE category = ? AND authorised_value = ? "); + $sth->execute($new_category, $new_authorised_value); ($duplicate_entry) = $sth->fetchrow_array(); unless ( $duplicate_entry ) { my $sth=$dbh->prepare( 'INSERT INTO authorised_values