From 0fbbc96d38f413a9e222f20aff5553c4901b6858 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 20 Jun 2013 18:20:31 +0200 Subject: [PATCH] Bug 10478: Sequential number generator Content-Type: text/plain; charset=utf-8 --- C4/Koha.pm | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 9976995..65ba6c0 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1503,6 +1503,33 @@ sub _isbn_cleanup { return; } +=head2 NextSequentialNumber + + Returns the next sequential number in a range (subranges possible) + + my $sh= NextSequentialNumber('shelfnumber'); + my $loc= NextSequentialNumber('shelflocation', $sh); + +=cut + +sub NextSequentialNumber { + my ($range, $subrange)= @_; + + my $sql=q/ +UPDATE sequential_numbers set counter= LAST_INSERT_ID(counter+1) +/; + my $dbh= C4::Context->dbh; + #my $dbname= C4::Context->config("database"); + + $dbh->do($sql); + #return $dbh->last_insert_id(undef, undef, 'sequential_numbers', 'counter'); + return $dbh->last_insert_id(undef, undef, undef, undef); + #first parameter could have been $dbname (MySQL ignores it) + #actually third and fourth are also ignored +} + + + 1; __END__ -- 1.7.7.6