Bugzilla – Attachment 43091 Details for
Bug 14627
GetAuthorisedValueByCode does not handle undef intelligently
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14627: Improve SQL query
Bug-14627-Improve-SQL-query.patch (text/plain), 1.17 KB, created by
Mark Tompsett
on 2015-10-04 07:29:51 UTC
(
hide
)
Description:
Bug 14627: Improve SQL query
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-10-04 07:29:51 UTC
Size:
1.17 KB
patch
obsolete
>From 290b7be83766cf9815dfd91f2f0489e822beab1b Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sun, 4 Oct 2015 03:13:26 -0400 >Subject: [PATCH] Bug 14627: Improve SQL query > >A field=NULL condition does not run properly. If category is >undefined, then don't include it in the query. >--- > C4/Koha.pm | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 910d6bb..856c302 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1262,9 +1262,16 @@ sub GetAuthorisedValueByCode { > } > > my $field = $opac ? 'lib_opac' : 'lib'; >+ my @params; > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("SELECT $field FROM authorised_values WHERE category=? AND authorised_value =?"); >- $sth->execute( $category, $authvalcode ); >+ my $sql = "SELECT $field FROM authorised_values WHERE authorised_value =?"; >+ push @params, $authvalcode; >+ if (defined $category) { >+ $sql .= ' AND category=?'; >+ push @params, $category; >+ } >+ my $sth = $dbh->prepare($sql); >+ $sth->execute( @params ); > while ( my $data = $sth->fetchrow_hashref ) { > return $data->{ $field }; > } >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14627
:
41266
|
43090
|
43091
|
44263
|
44264