From 8556cb5076b072cf4fef0752846358545635f330 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 27 Jul 2012 14:24:02 +0200 Subject: [PATCH] Bug 7919: Followup: using LEFT JOIN instead of JOIN for 2 files --- cataloguing/addbiblio.pl | 5 +++-- tools/batchMod.pl | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 7fe8975..89eb66c 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -221,8 +221,8 @@ sub build_authorized_values_list { else { my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; $authorised_values_sth->execute( + $tagslib->{$tag}->{$subfield}->{authorised_value}, $branch_limit ? $branch_limit : (), - $tagslib->{$tag}->{$subfield}->{authorised_value} ); push @authorised_values, "" @@ -528,8 +528,9 @@ sub build_tabs { my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; my $query = "SELECT authorised_value, lib FROM authorised_values"; - $query .= qq{ JOIN authorised_values_branches ON ( id = av_id AND ( branchcode = ? OR branchcode IS NULL ) )} if $branch_limit; + $query .= qq{ LEFT JOIN authorised_values_branches ON ( id = av_id )} if $branch_limit; $query .= " WHERE category = ?"; + $query .= " AND ( branchcode = ? OR branchcode IS NULL )" if $branch_limit; $query .= " GROUP BY lib ORDER BY lib, lib_opac"; my $authorised_values_sth = $dbh->prepare( $query ); diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 90e1a0b..bd52e94 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -265,12 +265,12 @@ if ($op eq "show"){ # now, build the item form for entering a new item my @loop_data =(); my $i=0; -my $query = qq{ - SELECT authorised_value, lib FROM authorised_values - JOIN authorised_values_branches ON ( id = av_id AND ( branchcode = ? OR branchcode IS NULL ) ) - WHERE category = ? - GROUP BY lib ORDER BY lib, lib_opac -}; +my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; +my $query = qq{SELECT authorised_value, lib FROM authorised_values}; +$query .= qq{ LEFT JOIN authorised_values_branches ON ( id = av_id ) } if $branch_limit; +$query .= qq{ WHERE category = ?}; +$query .= qq{ AND ( branchcode = ? OR branchcode IS NULL ) } if $branch_limit; +$query .= qq{ GROUP BY lib ORDER BY lib, lib_opac}; my $authorised_values_sth = $dbh->prepare( $query ); my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later. @@ -364,7 +364,7 @@ foreach my $tag (sort keys %{$tagslib}) { } else { push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); - $authorised_values_sth->execute( C4::Context->userenv ? C4::Context->userenv->{"branch"} : "", $tagslib->{$tag}->{$subfield}->{authorised_value} ); + $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value}, $branch_limit ? $branch_limit : () ); while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { push @authorised_values, $value; $authorised_lib{$value} = $lib; -- 1.7.7.3