Bugzilla – Attachment 35876 Details for
Bug 13702
Subroutine to check if a Biblio exists or is deleted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13702 - Subroutine to check if a Biblio exists or is deleted
Bug-13702---Subroutine-to-check-if-a-Biblio-exists.patch (text/plain), 2.16 KB, created by
Olli-Antti Kivilahti
on 2015-02-12 14:53:43 UTC
(
hide
)
Description:
Bug 13702 - Subroutine to check if a Biblio exists or is deleted
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-02-12 14:53:43 UTC
Size:
2.16 KB
patch
obsolete
>From 923255e99fdbb39dd07d6ea90f1b3cd577736ed2 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Thu, 12 Feb 2015 16:49:32 +0200 >Subject: [PATCH] Bug 13702 - Subroutine to check if a Biblio exists or is > deleted > >A handy helper function when looking for a biblio. >Is it alive? >Deleted? >or has it never existed (or DELETEd from the deleted* tables)? > >TEST PLAN: > >0. Make a code review. >--- > C4/Biblio.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 49 insertions(+) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 8d62a61..120c3aa 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -398,6 +398,55 @@ sub ModBiblioframework { > return 1; > } > >+=head2 Exists >+ >+ my $exists = C4::Biblio::Exists($biblionumber); >+ if ($exists == 2) { >+ print "Biblionumber $biblionumber exists in koha.biblio and koha.biblioitems"; >+ } >+ elsif ($exists == 1) { >+ print "Biblionumber $biblionumber exists in koha.deletedbiblio and koha.deletedbiblioitems"; >+ } >+ else { >+ print "Biblionumber $biblionumber doesn't exist in Koha DB"; >+ } >+ >+Finds out if the given biblionumber exists as an active Biblio or a deleted Biblio in Koha, or if it is no longer available. >+=cut >+ >+sub Exists { >+ my ( $biblionumber ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare( "SELECT 1 FROM biblio WHERE biblionumber=?" ); >+ $sth->execute( $biblionumber ); >+ my $exists = $sth->fetchrow(); >+ >+ unless ($exists) { >+ my $deleted = C4::Biblio::IsDeleted($biblionumber); >+ return $deleted; >+ } >+ return 2; >+} >+ >+=head IsDeleted >+ >+ my $deleted = C4::Biblio::IsDeleted($biblionumber); >+ >+@RETURNS Integer 1, if the given biblionumber exists in the koha.deletedbiblio-table. >+ otherwise undef. >+ >+=cut >+ >+sub IsDeleted { >+ my ( $biblionumber ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare( "SELECT 1 FROM deletedbiblio WHERE biblionumber=?" ); >+ $sth->execute( $biblionumber ); >+ my $deleted = $sth->fetchrow(); >+ return $deleted if $deleted; >+ return undef; >+} >+ > =head2 DelBiblio > > my $error = &DelBiblio($biblionumber); >-- >1.7.9.5
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 13702
: 35876